- Home /
Question by
ApplezGaming · Oct 18, 2012 at 06:17 PM ·
playerjumping
How to make my player jump?
i am trying to make my player able to jump and with the script i have at the moment it jumps a little bit when pressed but jumps to the height i have set it to when space is held. this is the script i have.
var playerSpeed : int;
var playerJump : int;
function Update () {
amtToMove = (playerSpeed * Input.GetAxis("Horizontal")) * Time.deltaTime;
transform.Translate(Vector3.right * amtToMove);
amtToJump = (playerJump * Input.GetAxis("Jump")) * Time.deltaTime;
transform.Translate(Vector3.up * amtToJump);
}
Comment
Answer by NecrosDk · Oct 18, 2012 at 08:10 PM
The easiest way to quickly simulate a jump would be to add a rigidbody to your object, and use:
rigidbody.addforce(Vector3.up * yourjumpforce); (However that is done in js)
The gravity will take care of the trip back down to the ground for you :)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
AI Follow Player "Tag" Help 1 Answer
Weapon switching 1 Answer
Player movement 0 Answers
Having trouble with player.transform 1 Answer