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.
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.
Ok, I have waited quite a while for this answer, has nobody have an answer to this o.O.I feel as if it is something simple but I just can’t quite nab it.
Oh btw I think I got it to start working, apparently I have to die then press play again and it works, but also how would I right the script so it works right away for one, and for to, its making it so that my object turns completely and its back is facing the player. Here is an image showing how the X,Y,Z are set up.
OK well JM Studios I modified your script and am very very close now. only problem is, it is rotating in the wrong direction. Because your script is rotating for X value when I need it for the Y value. Here is a video showing the error. Basically I want the enemy ship to start coming down and turning towards me, not show its back to me.
How many more non topic related subject titles will we need to crack the foundation of the search engine lol.
Sorry if that sounded over the top, just wondering if you can change your subject title to so something that may help the community in the future:) To Quote Tom H, Then we all win.