How do I destroy depending on position to another object.

Get help using Construct 2

Post » Tue Sep 30, 2014 3:23 pm

Hello World,

So what I am trying to do is destroy objects when they find themselves a certain number of pixels behind a certain object. Now I know what you're gonna ask "Why don't you just use outside of layout behavior?" or "Why don't you just place an object outside of layout at the position you want and everything that collides with it gets destroyed?" I can't use anything like that because(unless I understood this entire part completely wrong) the way I set up my game, the layers themselves don't move, they are prebuilt and the scroll is attached to the player, so he travels through them.

So I played around for a bit and ended up with an event that basically says every tick if Sky.X is less than Playerbox.X-600 then destroy Sky. Now this works for a few seconds, but as the player travels more his X obviously changes and after a while the sky starts getting destroyed even when it's ahead of the player. So I guess what I need is for the sky to get destroyed depending on the relative Playerbox.X-600?

Not sure how well I explained it, let me know if I have to be more clear. Thank you guys.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Tue Sep 30, 2014 10:11 pm

My crazy idea of the day...

Does your player move in a set direction like an infinity scroller or left and right, up and down like a platformer, or freely move like a huge space style game?

If its a one direction movement, have you tried pinning an invisible object 600 pixels behind your player and setting anything you want destroyed to be killed if it overlaps it?
The pinned object will pin at the distance relative to the pinned target upon the pin action, so if you create the pin kill object 600 pixels behind the player and then pin it to player it should keep that distance at all times killing anything that gets that far back...

Platformer would be tougher but if you pin it to angle as well it should "flip" to other side when you turn to go other way.. (not tested).

Freeflying type would be toughest using this unless you made the following destroyer object much large and maybe C shaped...
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
71
S
19
G
8
Posts: 640
Reputation: 9,701

Post » Wed Oct 01, 2014 1:09 am

One direction movement. Yeah, your idea could work, I'll test it out unless anyone comes up with something better, thanks.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335


Return to How do I....?

Who is online

Users browsing this forum: BiffanyPFH, Julot135, Yahoo [Bot], Zzarkz and 22 guests