Picking between instances of the same object

Get help using Construct 2

Post » Tue Nov 03, 2015 7:01 pm

Okay, how can I explain this...

I have a sprite object called Critter.
I want critters to do things (run away) if they get too close to each other.

In order to do this I want to use...

For Each Critter
Get Nearest Other Critter
Get Distance Between the two
If Distance is Less than 500
Run Away Function

The problem is all critters are instances of the same object, which means... I don't really know what it means but it's fucked up.
Pick nearest without picking yourself just... Doesn't seem to work.

This is what I've got...
I'm testing to see if I can just get a critter to move towards the closest other critter.


With this code, the movement actions just don't run.

I understand if further clarification is required.
Posts: 85
Reputation: 395

Post » Tue Nov 03, 2015 7:55 pm

You are missing a "Pick all Critter" somewhere along the way. The "For Each" essentially limit the SOL to a single Critter, to test against all critters in a sub-event, you have to include a "Pick all".
Posts: 984
Reputation: 19,503

Post » Tue Nov 03, 2015 9:40 pm


It's still a bit weird but seems to be working to some degree.

To help anyone else out: It only works in the following order:

System - Pick All
Object - Pick instances where not equal to UID
Object - Pick nearest

Now that I read it that makes sense. Thanks!
Posts: 85
Reputation: 395

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests