Follow Collision Polygons

Get help using Construct 2

Post » Mon Dec 09, 2013 2:18 am

Hey guys,

Is there a way making an object that follows another object's collision polygon lines ?



I don't have any idea about it. Any clue is greatly appreciated.
B
74
S
36
G
41
Posts: 444
Reputation: 26,317

Post » Mon Dec 09, 2013 2:30 am

The easiest way I can think of is to give the moving object a value like "dir" which will go up, down, left, or right (1 - 4), and then a collision polygon of basically one pixel.

Then every tick, check the current dir value, if not touching your object at offset of 1px to the direction they are trying to go in, then add 1 to dir. (if dir = 4, then dir = 1, etc)

Then add an action to move in the direction they currently have set.

I think this would be a slow method though, and haven't tested itJayjay2013-12-09 02:30:32
Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
127
S
43
G
18
Posts: 2,240
Reputation: 20,592

Post » Mon Dec 09, 2013 2:36 am

Thanks for fast reply @Jayjay! I will try it now.
B
74
S
36
G
41
Posts: 444
Reputation: 26,317

Post » Mon Dec 09, 2013 7:37 am

Hmm that method I said didn't work so well for me when I gave it a try, but here's a basic example of another method to do it! (A third option is to put sprites at every join position of the base sprite to tell your tracer-object which way to turn!)

https://dl.dropboxusercontent.com/u/4714446/FollowEdge.capx
Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
127
S
43
G
18
Posts: 2,240
Reputation: 20,592

Post » Mon Dec 09, 2013 3:15 pm

Another option is to set an image point at each collision polygon point, and have the moving object cycle through each image point.

Demo
Capx

I'm hoping we eventually get expressions for X and Y coordinates of collision polygon points, as it would make things like this a whole lot easier.zatyka2013-12-09 16:22:36
B
64
S
19
G
8
Posts: 341
Reputation: 12,195

Post » Mon Dec 09, 2013 11:06 pm

@Jayjay @zatyka thanks for the examples guys I will look them
B
74
S
36
G
41
Posts: 444
Reputation: 26,317

Post » Sun Dec 15, 2013 12:10 am

@zatyka Thanks a lot! That's exactly what I need.
B
74
S
36
G
41
Posts: 444
Reputation: 26,317


Return to How do I....?

Who is online

Users browsing this forum: Julot135, Magistross and 23 guests