[solved] Enemies kind of surrounding the player ?

Get help using Construct 2

Post » Sun Feb 01, 2015 3:07 pm

Hi.

I'd like my enemies to have a behavior like this (sort of) :
ia.png


Let me know if it's not clear enough :D

I'm pretty sure I need some math (angles and stuff) to do this but I don't have any clue about how to do this. Plus I don't know math. :D

Any advice/idea ?
You do not have the required permissions to view the files attached to this post.
Last edited by Coin-coin le Canapin on Mon Feb 02, 2015 10:46 am, edited 1 time in total.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Mon Feb 02, 2015 6:42 am

Give them the "Custom Movement" behavior with Set Angle towards position Player.X, Player.Y.

And you might want to combine that with:

System > Distance (Player.X, Player.Y, Enemy.X, Enemy.Y) <200

or something like it..

Hope this helps.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Mon Feb 02, 2015 10:45 am

Thank you for your reply. :)

I managed to do exactly what I intended using two algorithms :
https://math.stackexchange.com/question ... d-distance to defines two very distant point related to the enemy's current angle
And http://devmag.org.za/2009/04/17/basic-c ... 2d-part-2/ to test the collision between a circle and the line defined by the previous two distant points.
surrounding.png


You can try it here : http://canapin.com/construct/scarletland/01/ and use the arrows to move (and left click to shoot)
Since it may interest other people, I attach the commented .capx.
You'll also need the LiteTween behavior : behavior-litetween_t70700
You do not have the required permissions to view the files attached to this post.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276


Return to How do I....?

Who is online

Users browsing this forum: nahima and 9 guests