- Home /
Projectile Script
Where am I going wrong? The projectile will not move forward.
var enemy : Transform; var shot : Rigidbody; var waitTime = 3; var speed = 10;
function Start () {
var dist : float = Vector3.Distance(enemy.position, transform.position); Debug.Log(dist); yield WaitForSeconds (waitTime); projectileSpeed = dist; Shoot();
}
function Shoot () { print ("shoot!"); var projectile : Rigidbody = Instantiate(shot, transform.position + Vector3(2,2,0), transform.rotation); projectile.velocity = transform.forward * speed; }
Thanks!
Answer by GesterX · May 08, 2011 at 04:29 PM
The line to set the velocity should be:
projectile.velocity = transform.TransformDirection(Vector3.forward * speed);
Your answer
Follow this Question
Related Questions
Slow automatic shooting script? 2 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
projectile limitation problems 1 Answer
Shooting Script Bullet Doesnt Fire 2 Answers
Shooting in 2 dimensional games 2 Answers