Missile or projectiles that follow enemy.
how to make?
using ‘enemy’ tag to enemy cube?
Missile or projectiles that follow enemy.
how to make?
using ‘enemy’ tag to enemy cube?
var enemy : Transform;
var speed = 20;
function Start () {
while (true) {
rigidbody.velocity = (enemy.position - transform.position).normalized* speed;
yield;
}
}
that should work. If you want to find the ‘enemy’ variable in another way, then please specify, but that function will cause it to fly at the enemy.
[edit]
actually, adding a force might be more realistic
var enemy : Transform;
var speed = 20;
function Start () {
while (true) {
rigidbody.AddForce ((enemy.position - transform.position).normalized* speed);
yield;
}
}