Hi,
I am working on a Tanks Game. Enemy tanks fire on Player Tank automatically. I have written code for Enemy Rocket but my code is not working accurately. I want that Enamy Rocket will move towards Player Tank?
This is my code .
function MissileFiring()
{
var targetVector : Vector3 = heroTankObj.transform.position-transform.position;
transform.TransformDirection(-(heroTankObj.position-transform.position) * 2.0);
var position : Vector3 = new Vector3(-8, 0, 0);
position = transform.TransformPoint(position);
Instantiate (Missile, position, Quaternion.identity);
ObjMissile = Missile.GetComponent(MissileControllerOfEnemy);
ObjMissile.moveTowards = targetVector;
// move towards will be given as a addForce in Update function
}
Can anyone help me? Waiting for reply,