I currently am working on a game that i just finished(used the unity tutorial roll a ball) and i want to add on to it. What i want to do i to let the player be able to jump but i wrote this script(i have no idea to code any language at all) and i want to know why it isnt working here is what i am talking about my code: i have fixed update and inside that the axis that move the ball on the x and zed axis and i have a vector 3 here is what im talking about :void FixedUpdate() { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); Vector3 movement = new Vector3 (moveHorizontal,0.0f, moveVertical); rb.AddForce (movement * speed);
but thats not really my problem the problem is i have this code andd its not quite working the way i want it to work : if (Input.GetKeyDown (KeyCode.Space)) { rb.AddForce(0, gravity,0); }
with gravity being the value of 10 by default, to add one more bit of information here i have this function to hold it all together:void rigid() { rb = GetComponent<Rigidbody>(); }
you are adding gravity force upwards for a single instance, that means the character is in zero-g for one frame. triple that and you should be able to see a small jump.