# car movement follow player?

Get help using Construct 2

### » Mon Dec 24, 2012 3:29 am

I'm trying to get an enemy ai spacecraft to point towards my player and I think I have it figured out with the exception of the angles. Having a brain cramp. So heres how I think it should be done.

check to see if player is left of center(enemy) press left
check to see if player is right of center(enemy) press right.

So what angles am I checking for in this case with the conditions? Or is there an easier way?
lanceal2012-12-24 03:30:27
B
71
S
22
G
15
Posts: 705
Reputation: 15,787

### » Thu Dec 27, 2012 9:25 am

If I understand your question correctly, setting angle is easy enough, just use Every tick, AI Set angle towards (Player.X, Player.Y).

capx

Is that what you meant, or am I missing something?
B
57
S
15
G
10
Posts: 912
Reputation: 12,011

### » Thu Dec 27, 2012 12:04 pm

There is an action called: Rotate toward position, use it with the (player.X,player.Y) and the spacecraft will rotate at the desiered angle, the initial angle of the spacecraft(at the strat of layout) is 0, and it should be pointed to right (->) like this, otherwise, you will be confused when you'll use the rotate toward pos.wildmedia2012-12-27 12:04:59
B
15
S
3
G
2
Posts: 42
Reputation: 2,412

### » Thu Dec 27, 2012 2:01 pm

@GeometriX @wildmedia,

Thanks you two. The problem was I was using the car behavior. Rotating the angle rather then using the simulate movement made it look real choppy. So what I did was check first to see if the angle was withing 2 degrees of the player. If so then it continues forward. If not then I check the is clockwise condition. If its clockwise I simulate right, if its not clockwise I simulate left movement. I still wish there was an easier way though. :( thanks for trying you two. :)
B
71
S
22
G
15
Posts: 705
Reputation: 15,787

Return to How do I....?

### Who is online

Users browsing this forum: 99Instances2Go, Greaver, justifun, MPPlantOfficial, semaso, Yahoo [Bot] and 36 guests