So I have a jump script, but the player goes up only and doesn’t come back down. Help please
float jumpSpeed = 5f;
if (Input.GetKey (KeyCode.Space))
{
transform.Translate (Vector3.up * jumpSpeed * Time.deltaTime);
}
So I have a jump script, but the player goes up only and doesn’t come back down. Help please
float jumpSpeed = 5f;
if (Input.GetKey (KeyCode.Space))
{
transform.Translate (Vector3.up * jumpSpeed * Time.deltaTime);
}
transform.Translate is just a normal translation function, if you wish to have the effect like what you mention, you need to use addforce powered by rigidbody
Before you do this, you need attach rigidbody component into your player object
then in script
float jumpSpeed = 5f;
if (Input.GetKey (KeyCode.Space))
{
GetComponent<RigidBody>().AddForce(Vector3.up * jumpSpeed * Time.deltaTime);
}
adjust the jumpSpeed yourself