i am trying to follow an fps tutorial but it is in js but i use c# the gravity is set to -9.87 and the character is only 2 units in height i can jump but it goes up a really small amount and then falls down really slowly here’s the script
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
public float walkAcceleration = 5;
public mouseLook Script;
public float maxWalkSpeed = 20;
Vector2 horizontalMovement;
public float jumpVelocity = 20;
public bool grounded = false;
public float maxSlope = 60;
// Update is called once per frame
void Update () {
horizontalMovement = new Vector2(rigidbody.velocity.x, rigidbody.velocity.z);
if(horizontalMovement.magnitude > maxWalkSpeed){
horizontalMovement.Normalize();
horizontalMovement *= maxWalkSpeed;
}
rigidbody.velocity = new Vector3(horizontalMovement.x, 0, horizontalMovement.y);
transform.rotation = Quaternion.Euler(0, Script.currentyRotation, 0);
rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * walkAcceleration, 0, Input.GetAxis("Vertical") * walkAcceleration);
if(Input.GetButtonDown("Jump") && grounded){
rigidbody.AddForce(0, jumpVelocity, 0);
}
}
void OnCollisionStay (Collision collision){
foreach(ContactPoint contact in collision.contacts){
if(Vector3.Angle(contact.normal, Vector3.up) < maxSlope){
grounded = true;
}
}
}
}
please help i am really confused