Hey guys so I got the first three levels up and running for my game, but then want to go to a next difficulty. In this I wanted my enemies to turn and move towards the player (But not to fast ofc) just to make them harder to dodge and destroy. If you don’t know what this game is go ahead and test it out here: It is very basic atm and I haven’t done much with the visuals.
OK so from based off of that game, all of the enemies go strait down, so its kinda easy. For the next difficulty I wanted them to turn and fall towards the player more. I tried to make my own script to do this but it didn’t work, here is what I have so far
This is the original working script of just the normal enemies that you see in the game above.
var enemySpeed: int;
function Update ()
{
amtToMove = enemySpeed * Time.deltaTime;
transform.Translate(Vector3.down * amtToMove);
if(transform.position.y <= -5)
{
transform.position.y = 7;
transform.position.x = Random.Range(-6,6);
}
}
This is the attempt to make them look at the player and turn towards them according the the speed I want them to through the damp var. Only problem is, they don’t turn ^^ they are doing the exact same thing as my other script:
var enemySpeed: int;
var LookAtTarget:Transform;
var damp = 6.0;
function Update ()
{
amtToMove = enemySpeed * Time.deltaTime;
transform.Translate(Vector3.down * amtToMove);
if(transform.position.y <= -5)
{
transform.position.y = 7;
transform.position.x = Random.Range(-6,6);
}
if(LookAtTarget)
{
var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation ,rotate ,Time.deltaTime * damp);
}
}
So yea basically I’m asking how I would fix/change my script to get this to work, thanks.