- Home /
Question by
MilPlayz · May 09, 2018 at 06:07 PM ·
c#playerjumpingplayer movement
How do I jump?
Sooo... I've been trying to make my player be able to jump for about 5 hours now but I havent been able to do it... so can you please help me do it, also rb.AddForce() doesnt work. Heres my code:
CharacterController charControl;
public float walkSpeed;
public Rigidbody rb;
private void Awake()
{
charControl = GetComponent<CharacterController>();
}
void Update()
{
MovePlayer();
}
void MovePlayer()
{
float horiz = Input.GetAxis("Horizontal");
float vert = Input.GetAxis("Vertical");
Vector3 moveDirSide = transform.right * horiz * walkSpeed;
Vector3 moveDirForward = transform.forward * vert * walkSpeed;
charControl.SimpleMove(moveDirSide);
charControl.SimpleMove(moveDirForward);
}
}
Comment
Could you please format the code into Code Sample (CTRL+$$anonymous$$)
Your answer
Follow this Question
Related Questions
Player wont jump (visual script),2d player does not jump (visual script) 1 Answer
Player rapidly accelerating instead of stopping 1 Answer
How to prevent player from moving in air while jumping in place?? 0 Answers
Multiple Cars not working 1 Answer
How can I make my jumping only work when I'm touching the ground? 2 Answers