Why are both of these running at the same time?

0 favourites
  • 3 posts
From the Asset Store
Time rewind like in "Braid". Choose objects that will be affected by time rewind
  • Ok, so long story short, I am developing a button mechanic in my game where certain enemy types can overlap the button and it activates a gate.

    One specific enemy type, the ice grunt, has to have its own condition for this to work, as it's collisions get disabled but then reenabled when it is downed.

    Ice grunt IS part of the Enemies family, but this shouldn't effect the outcome of this code, as the code that causes the button to activate when theyre in range of the button's LOS ONLY triggers when they aren't already colliding with it.

    I apologize if this code seems a bit messy/disorganized, I've been trying to rewrite it in different ways to get it to work, but none did.

    For some reason, both the deactivation and activation code are triggered when the downed ice grunt overlaps the button. Why is this happening?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You set a variable that's never used, you use animation condition instead? I would keep it to the variable as it's easier to debug rather than checking if an animation is playing.

    Also for the downed enemy it might be easier to use a Family instance variable for example isDown then you can use the condition 'Enemy is overlapping button' and replace the LOS thing with 'Enemy isDown=false'.

    To debug this it's difficult, what you mentioned about disabling the collision is not shown in the screenshots so we can't know if that's happening at the time of collision. But yeah do the above and simplify it down to get rid of LOS and only use Enemies conditions to start debugging the problem. If disabling the collisions is part of the gameplay itself you could still use it but not as part of the conditions with the buttons.

  • With so many different conditions it's tricky to make such code work corectly. Also, OR-blocks in Construct are difficult to work with. I would suggest changing the entire thing like this:

    On every tick
    For Each Button 
    
    .. Local variable activate=0
    
    .. Player overlapping button
    .. OR Boulder overlapping button : Set activate to 1
    
    .. Enemies animation "IceGiant" NOT playing
    .. Enemies overlapping button : Set activate to 1
    
    
    .. Enemies animation "IceGiant" IS playing
    .. Button has LOS to Enemies : Set activate to 1
    
    
    // And now you check if the button should change its state
    .. Button is activated
    .. activate=0 : Button set activated to false, play sound
    
    .. Button is NOT activated
    .. activate=1 : Button set activated to true, play sound
    
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)