Hey guys I wrote a c# script for running and jumping…unfortunately it doesn’t allow me to run and jump at the same time…I can run and I can jump but not both at the same time anyone mind helping me out on this one?
int isstuned = 0;
//if the player isn't stunned
if(isstuned == 0)
{
//if space is pressed and the ray is reading a collision is down or if up arrow is pressed and the ray is reading a collision of down
if(Input.GetKeyDown("space") && Physics.Raycast(transform.position, -transform.up,1) || Input.GetKeyDown(KeyCode.UpArrow) && Physics.Raycast(transform.position, -transform.up,1))
{
//make the player transform up by the speed of jumpforce using an impulse type force
rigidbody.AddRelativeForce(transform.up * jumpforce, ForceMode.Impulse);
}
//if a or left arrow is pressed
if (Input.GetKey("a") || Input.GetKey(KeyCode.LeftArrow))
{
//push left
rigidbody.velocity = -transform.right * curspeed;
}
//if d or right arrow is pressed
if (Input.GetKey("d") || Input.GetKey(KeyCode.RightArrow))
{
//push right
rigidbody.velocity = transform.right * curspeed;
}
}