Hello, people!
I really don't understand!
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0f, moveVertical);
rb.AddForce (movement * speed);
if (Input.GetButtonDown ("Jump"))
{
rb.AddForce (transform.up * jump);
}
}
This code attached to sphere. I want that ball can jump to the up, but addForce works in local space, I mean when I press down jump, force is pushing ball in axis Y but local not Global. When ball is rolling and his axis X in down direction ball doesn't jump.
But in scripting said AddForce works in global space???
Can you explain me?
↧