- Home /
Question by
Fadawar · Apr 03, 2015 at 01:13 AM ·
ridgidbody
fire a rigidbody at a sphere
I have it so that there is a sphere in the middle of the room, for the player I have a spawnpoint for bullets that constantly looks at the sphere how ever when I create the bullets and add force to its rigidbody (rigidbody.addForce(spawnpoint.transform.forward)), the bullets launch in different directions. Thank you!!!
Comment
Answer by _joe_ · Apr 03, 2015 at 01:24 AM
You need to transform from local to world space :
Vector3 newForward = this.transform.TransformDirection(Vector3.forward);
b.rigidbody.AddForce (newForward * 800);
http://docs.unity3d.com/ScriptReference/Transform.TransformDirection.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613192029im_/https://answers.unity.com/themes/thub/images/avi.jpg)