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

Problem with AddForce and direction

$
0
0
So..... I have a character that fires a ball; when the ball is fired towards the floor I want the character to have force added in the opposite direction to that which the ball was fired. I have tried various ways of doing this, but in each case, no matter what the Vector3 fed into AddForce is the character just appears to go straight up. All 3 of these lines get the same sort of Vector3 result: jumpAngle = transform.position - bodyAimer.transform.position; jumpAngle = aimer.TransformDirection(-Vector3.right); jumpAngle = -aimer.transform.right; the jumpAngle is fed into AddForce here: transform.rigidbody.AddForce (jumpAngle*(fireForce/2)); this script is on the player object which does have a rigidbody if it's not firing at the floor the following line does correctly fire the ball in the direction the aimer is pointing: proj.rigidbody.AddForce (aimer.transform.right * fireForce); Pic below should help explain the setup: ![alt text][1] does anyone have any idea why it just goes straight up every time? What am I doing wrong here? PS: jumpAngle is a public Vector3, so I can see what it gets set to, fireForce is a public float. [1]: /storage/temp/33899-directionproblem.jpg

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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