Hello. So I wanted to add crouch and double jump to my character and I have no idea how… BTW I’m making kinda parkour game, so my object will touch with many other objects, so script with touching only ground (for false jump) doesn’t count. I also need sprint script (speed * 2, but for some reason it doesn’t work for me, I deleted it from scrip. Thanks for all the help
using System.Collections;
using UnityEngine;
public class CharacterMovement : MonoBehaviour
{
public float speed = 10.0f;
public float jumpSpeed = 100f;
private float sprintSpeed;
public Rigidbody rb;
private float crchSpeed;
private void Start()
{
Cursor.lockState = CursorLockMode.Locked;
rb = GetComponent<Rigidbody>();
crchSpeed = speed;
sprintSpeed = speed * 2;
}
private void Update()
{
float translation = Input.GetAxis("Vertical") * speed;
float straffe = Input.GetAxis("Horizontal") * speed;
translation *= Time.deltaTime;
straffe *= Time.deltaTime;
transform.Translate(straffe, 0, translation);
if (Input.GetKeyDown("escape"))
{
Cursor.lockState = CursorLockMode.None;
}
if (Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(Vector3.up * jumpSpeed);
}
}
}