- Home /
Shooting in the LookAt direction
HI!
So at the moment i have a simple script which determines the direction of a bullet using AddForce:
var bulletSpeed : float = 200.0;
function Update () {
rigidbody.AddForce(Vector3(bulletSpeed, 0, 0));
}
I also use a simple LookAt script for my 'gun' to look at an object variable:
var myTarget : Transform;
function Update () {
transform.LookAt(myTarget);
}
All i want is for my bullet to travel in the same direction as the LookAt...is this possible?
Thanks, Tom :)
Comment
Answer by Jay2x · Oct 14, 2011 at 02:23 PM
rigidbody.AddForce*(Vector3.forward bulletSpeed);
You have to put a reference about player's orientation.
Thank you, i'll start playing about with the script now :)