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.

Image

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

I understand if further clarification is required.
B
5
S
1
Posts: 85
Reputation: 545

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".
B
75
S
31
G
27
Posts: 1,012
Reputation: 20,759

Post » Tue Nov 03, 2015 9:40 pm

Alright!

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!
B
5
S
1
Posts: 85
Reputation: 545


Return to How do I....?

Who is online

Users browsing this forum: max2612 and 4 guests