picking problem - instances of an object inside a family

0 favourites
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • can someone explain why all my enemies turn when one of them hits a colision with a stop and turn sign?

  • ok i am coming to the conclusion that construct is just terrible at picking objects 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.

    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.

  • 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.

  • In general, I really can't help without a minimal .capx demonstrating the problem (ideally with just 1 or 2 events).

  • 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

  • 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 ! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    C-7 : i want to do it with colision objects - as it makes level design much user friendly

  • 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

  • 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

  • lennaert in your example there is no waiting - for the waiting part the enemy must stop moving for 1.5 seconds.

    The waiting part is quite important to me

    Tuiii your example does it, but instead of instances it uses clones. Can it also work with instances inside a family?

    I am looking for a way to be able to do both. Instances and other members of family should have individual behavior.

    Creating another instance of one of the objects results in breakage again.

    So both still dont solve the issue.

    Ashley Have we uncovered a limitation to construct's family system?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Just set your state to something else, "x", before the Wait so that the "wait" code doesn't repeat.

    http://www.blackhornettechnologies.com/ ... w_bht.capx

    (It better to use a Timer here, rather than Wait.)

  • Sorry, totally missed you wanted them to wait, here's another example

  • blackhornet This actually solves it - without using 'for each'... but it leaves me confused.

    looking at it - it seems illogical to me. It goes against what I've learned in programming.

    Shouldnt setting state to "x" stop all the events bellow that from executing?

    Also I used trigger once before - why didnt that work and this does?

    In what order exactly is the event sheet in C2 executing things?

    Ashley please explain

    lennaert thank you. In your case the solution was to make a manual timer with a new variable

    But it still has an issue - it turns too early. It should turn when it starts walking in the other direction, not when it stops.

    They are both elegant solutions. I will look further into using them. In this case I want to learn from them both

  • The problem is if you leave the state in "wait", event 4 runs constantly. You want this event to stop running while the Wait runs, and then the events after the Wait proceed, setting the state back to "walk".

    That's why a Timer makes this simpler, in my opinion. the code is easier to follow.

    Here's two simplifications.

    http://www.blackhornettechnologies.com/ ... r_bht.capx

    http://www.blackhornettechnologies.com/ ... 2_bht.capx

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)