Collission with or distance

Get help using Construct 2

Post » Thu Nov 01, 2012 7:49 am

When I use:

Player collision with object -> Destroy

It all works fine and the object is destroyed and only the object in collision with player.

But I want to use Distance(x1, y1, x2, y2) instead of collission with round objects to use the CPU less.

My problem is that Distance(Player.x, Player.y, object.x, object.y) -> Destroy, destroys all similar objects when true, and not just the one in "colission".

So my question is - how do I do so it's only the one in "colission" that is destroyed and not all similar objects on the layout?

And also - does the distance expression use less CPU power than "colission with" polygons?. I have many collisions in my game, so even a few % optimization is deffinately worth the effort.

B
7
S
3
Posts: 109
Reputation: 1,645

Post » Thu Nov 01, 2012 3:09 pm

Hmm... I think the only way to make this method work is to use a "For Each" qualifier, so Construct checks for each object individually. The only problem there is I've found For Each loops to be fairly draining on CPU, so it may not be worth the effort. Someone more experienced than me may have a more valuable opinion, but that's what I've found.
B
7
G
1
Posts: 27
Reputation: 991

Post » Thu Nov 01, 2012 6:41 pm

Use a sub event to "pick nearest" when distance is below your threshold, then destroy that one it filters out.

B
50
S
21
G
8
Posts: 844
Reputation: 10,299


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests