Skip to content

Add Unity first-person CharacterController player script for fruit collection game - #1

Open
noma-studio wants to merge 1 commit into
mainfrom
codex/create-player-movement-script-for-fruit-game
Open

Add Unity first-person CharacterController player script for fruit collection game#1
noma-studio wants to merge 1 commit into
mainfrom
codex/create-player-movement-script-for-fruit-game

Conversation

@noma-studio

Copy link
Copy Markdown
Owner

Motivation

  • Provide a simple first-person controller for the fruit collection game that supports WASD movement, mouse camera look, and gravity using Unity's CharacterController.
  • Offer a ready-to-use player script that can be attached to a player GameObject and wired to a camera for FPS-style controls.

Description

  • Added Assets/Scripts/FruitCollectorPlayerController.cs which implements movement, gravity, and mouse look in a single component.
  • Uses [RequireComponent(typeof(CharacterController))] and default moveSpeed of 5f and gravity -9.81f for natural motion.
  • Implements yaw on the player transform and clamped pitch on the playerCamera, auto-finding Camera.main if playerCamera is not assigned, and locks/hides the cursor on start.
  • Handles grounded state with a small negative vertical velocity reset and applies vertical velocity to CharacterController.Move each frame.

Testing

  • Verified the created file contents with nl -ba Assets/Scripts/FruitCollectorPlayerController.cs, which displayed the new script successfully.
  • Committed the new file and confirmed repository state with git status --short, with the commit operation succeeding.
  • No Unity editor or runtime tests were executed in this environment.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant