Write a script for a simple player cube that uses only the old Input Manager:
- Forward/back (W/S) and left/right (A/D) movement
- Jump on spacebar press
- Shoot a sphere on left mouse button click (in the camera's forward direction)
- Use
Input.GetAxis("Vertical")andInput.GetAxis("Horizontal") - Multiply by speed and
Time.deltaTime - Move the cube via
transform.Translate
- Only when the player is grounded (
isGroundedcheck) - Use
Input.GetKeyDown(KeyCode.Space) - Add a
Rigidbodyand apply upward force (AddForce)
- Instantiate a sphere (prefab) in front of the player
- On left mouse button click (
Input.GetMouseButtonDown(0)) - Give the sphere forward velocity via
Rigidbody.velocity
- Add sprint while holding
LeftShiftusingInput.GetKey
PlayerController.cs (main script)
Bullet.prefab (sphere + collider + Rigidbody)
Ground (plane with collider)
- Cube moves smoothly and doesn't fall through the ground
- Jump works only on ground
- Left mouse click spawns a ball flying forward
- No console errors