picking problem - instances of an object inside a family

Get help using Construct 2

Post » Fri May 20, 2016 2:33 pm

can someone explain why all my enemies turn when one of them hits a colision with a stop and turn sign?
Image
Last edited by blurymind on Fri May 20, 2016 5:45 pm, edited 1 time in total.
B
40
S
15
G
4
Posts: 426
Reputation: 5,843

Post » Fri May 20, 2016 3:12 pm

ok i am coming to the conclusion that construct is just terrible at picking objects :lol: just terrible

I nested all the enemy code under an "for each" - that stopped instances in the family from affecting each other's state. It however did not stop them complely - when both instances have the same state - one affects the other still - even if other conditions are different.

:lol:

any ideas on how to deal with this?

Perhaps @Ashley might know?

has anyone ever managed to get two enemy instances to have individual behaviors and not affect other instances or members of the family?
Can construct do that at all?
how?

godot will never have a problem like that because it is object oriented.
B
40
S
15
G
4
Posts: 426
Reputation: 5,843

Post » Fri May 20, 2016 3:38 pm

I haven't really had problems with picking or handling multiple enemies independently. An example capx would be easier, but the second half under the "wait" could be organized better (and may be why you're having problems). Give your enemies a private variable 'timer'.

(assuming it's all under a For Each loop)
If state = "wait"
---Trigger once ----> Set speed 0, set timer to enemies.turnTime
---If enemies.timer>0 ----> subtract dt from self.timer
---Else, if enemies.timer <or= to 0 ----> (put your flipping and state change code here as subevents)

A timer, I've found, is a much more controlled way to handle things like this and could be where your picking errors are cropping up.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Fri May 20, 2016 3:48 pm

In general, I really can't help without a minimal .capx demonstrating the problem (ideally with just 1 or 2 events).
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,842

Post » Fri May 20, 2016 3:49 pm

enemies state="wait" will require a "for each enemies" loop above it to handle multiple enemies individually, otherwise it will control all enemies when 1 has the wait state.

Same goes for enemies state="patrooling"

ie

event:
for each enemies
enemies state="patrooling"


and

event:
for each enemies
enemies state="wait"

Ideally, you have both the compare statements below 1 for each enemies
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Fri May 20, 2016 5:15 pm

@Ashley : here is an example file:
https://we.tl/EroGCi1BAz

it works when you have only one instance of the enemy and completely breaks when there is more than one.
To see what i want in action, delete the second instance

@lennaert : doesnt work ! :)

@C-7 : i want to do it with colision objects - as it makes level design much user friendly
B
40
S
15
G
4
Posts: 426
Reputation: 5,843

Post » Fri May 20, 2016 5:18 pm

Ohw you should add the collision detection in the event with the for each loop

event
on collision
for each enemies
state = "patrooling"
sub events
etc


and

for each enemies
state = "waiting"
sub events
etc
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Fri May 20, 2016 5:27 pm

@lennaert - can you screenshot your event sheet or share a fix file? I tried what you suggest and the second instance still has issues - it flips out when arriving to the colision at the same time the first instance does
B
40
S
15
G
4
Posts: 426
Reputation: 5,843

Post » Fri May 20, 2016 5:49 pm

Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Fri May 20, 2016 5:50 pm

B
22
S
4
G
3
Posts: 61
Reputation: 2,683

Next

Return to How do I....?

Who is online

Users browsing this forum: blackhornet, brunopalermo, jorgmaquoi, Rable, unicornspitfire and 9 guests