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

AddForce doesn't follow rotation

$
0
0
Hello, I have a problem with AddForce. It will always shoot like the original angle was (which means if I turn 90 degree on the left it will look like I shoot the rock not straight but at a 90° angle). I tried basically everything, be it local/global rotation. Attaching is to another object and doing the local/global rotation thing with it too and nothing works. This is not kinematic and this is not frozen on som axis. Here is the code : if(Input.GetKey(KeyCode.T)) { ThrowPower += Time.deltaTime * 20; } if(Input.GetKeyUp(KeyCode.T)) { newRock = (GameObject) Instantiate (Rock, Rock.transform.position, Rock.transform.rotation); newRock.rigidbody.AddForce (Vector3.up * 10f * ThrowPower); newRock.rigidbody.AddForce (Vector3.forward * 15f * ThrowPower); newRock.rigidbody.useGravity = true; newRock.collider.isTrigger = false; ThrowPower = 0; RockNb -= 1; } And here is picture of the Inspector : http://i.imgur.com/qO5Jbdb.png This is the main rock properties, this is what is instanciated. The main rock is the child of the first person controler. I hope people can help me. Thank you in advance.

Viewing all articles
Browse latest Browse all 1264


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