Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Add force only on local space

$
0
0
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?

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>