How do I make enemies oscillate around the player?

Get help using Construct 2

Post » Thu Jul 17, 2014 11:10 am

Thank you, I'll make it and post it :)
Black Bobby The Hole Greenlit with 303 votes.
B
36
S
8
G
1
Posts: 163
Reputation: 3,029

Post » Thu Jul 17, 2014 11:12 am

To get the distance from the enemy to the player use this:

distance(enemy.x,enemy.y,player.x,player.y)

if you want to know if this distance is less than 100 pixels use:

system compare two values: distance(enemy.x,enemy.y,player.x,player.y) < 100

the distance is measured in every direction so 100 is like a circle around player.x,player.y with a radius of 100px
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jul 17, 2014 2:55 pm

Thank you very much guys.

It runs very smoothly.

I added a pathfinding so that the enemy will move towards the player and when it's at 250 it will rotate. There are some minor issues, such as when the enemy rotates at the 90 angle it doesn't go smoothly but instant so it's a bit eye catching. And if you move towards the enemy it can overlap the player and it will just rotate on the player's spot. Even so, it looks great and I'm sure I can find some workarounds for these.

Image
Black Bobby The Hole Greenlit with 303 votes.
B
36
S
8
G
1
Posts: 163
Reputation: 3,029

Post » Thu Jul 17, 2014 3:03 pm

Actually due to the pathfinding I had to change the 90 degrees to 89 because it was starting to get glitchy after 1 revolution.
Black Bobby The Hole Greenlit with 303 votes.
B
36
S
8
G
1
Posts: 163
Reputation: 3,029

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests