So, I’m trying to make a movement script for my character (I’m pretty new with this stuff) and I think I’ve got most of it done, but I don’t really know how to make my character jump (also my character flies off the ground whenever i start the game.)
Anyways here’s the Script:
public class Sprint : MonoBehaviour
{
//Movement and jump
public float NormalSpeed = 12f;
public float SprintSpeed = 20f;
public float Jump = 5f;
public bool grounded;
public LayerMask whatIsGround;
public bool readyToJump = true;
Rigidbody rb;
private Vector3 normalVector = Vector3.up;
void start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
transform.Translate(h * NormalSpeed * Time.deltaTime, 0f, NormalSpeed * v * Time.deltaTime);
if (Input.GetKey(KeyCode.LeftShift))
{
NormalSpeed = SprintSpeed;
}
if (Input.GetKeyUp(KeyCode.LeftShift))
{
NormalSpeed = 12f;
}
Tons and tons of tutorials out there for first person controllers with jumping, so it doesn’t make any sense at all for one of us to retype one of them for you here. Google Youtube for more.
I see you’re using a rigidbody above, but if you would be happy with a simple character controller mover, here is a super-basic starter prototype FPS based on Character Controller (BasicFPCC):
That one has run, walk, jump, slide, crouch… it’s crazy-nutty!!