Hey guys I’m a beginner with using unity and I wanted to add a jump pad to my game, so that when the character is on top of the jump pad and presses the spacebar, the character will jump. I was trying to do this using the rigid body, but I couldn’t get it to work.This is what I have:
public float speed;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Jump pad")
{
if (Input.GetKey("space"))
{
Vector3 movement = new Vector3(0.0f, 100.0f, 0.0f);
rigidbody.AddForce (movement * speed * Time.deltaTime);
}
}
}
I have the script attached to the player, I have the right tag for the jump pad, and I added a rigid body component to the jump pad. Can anyone help?