I have FirstPersonPlayerMovement script attached to a simple capsule player in my scene. It has a rigidbody, all values set to default except for some constraints. But my player falls way too slow when walking off ledges. **Can someone let me know whats wrong?**
public float speed = 5;
public float gravity = -9.81f;
[Header("Running")]
public bool canRun = true;
public bool IsRunning { get; private set; }
public float runSpeed = 9;
public KeyCode runningKey = KeyCode.LeftShift;
Rigidbody rigidbody;
/// Functions to override movement speed. Will use the last added override.
public List> speedOverrides = new List>();
void Awake()
{
// Get the rigidbody on this.
rigidbody = GetComponent();
}
void FixedUpdate()
{
// Update IsRunning from input.
IsRunning = canRun && Input.GetKey(runningKey);
// Get targetMovingSpeed.
float targetMovingSpeed = IsRunning ? runSpeed : speed;
if (speedOverrides.Count > 0)
{
targetMovingSpeed = speedOverrides[speedOverrides.Count - 1]();
}
// Get targetVelocity from input.
Vector2 targetVelocity =new Vector2( Input.GetAxis("Horizontal") * targetMovingSpeed, Input.GetAxis("Vertical") * targetMovingSpeed);
// Apply movement.
rigidbody.velocity = transform.rotation * new Vector3(targetVelocity.x, rigidbody.velocity.y, targetVelocity.y);
}
----------
## What I've Tried: ##
- Changing the Mass, Drag, and Angular Drag of the rigidbody attached to the player. Nothing budged. right now they're defaulted again.
- Changing the gravity in Project Settings. Nothing.
- Changing the size of the player. I changed the players size to 3, 3, 3 since it was too small to fit the scene, but even when rescaling it back to original values (1, 1, 1), nothing happened again.
- Checking for any loose rigidbodies in the child gameObjects of the player.
----------
It must be something with the code, it really isnt my best work. Thanks for any help you can provide!
↧