How do I make an enemy that disappears, then reappears?

0 favourites
  • 12 posts
From the Asset Store
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.
  • I want to make an enemy that disappears, and then reappears to attack you, but I don't want you to be able to make contact with him unless he his visible. I've tried to use variables, but I don't think that I'm even close to what I want. I can supply an example of my capx, but it might take some time.

  • Use an instance variable if there are multiple of them. Call it "hidden" and make it a boolean or whatever you want, then do whatever you do to decide when the enemy hides, and make hidden true at the same time.

    You can then say:

    if hidden = true
         enemy: set collisions disabled
    else
         enemy: set collisions enabled
    [/code:14i82su3]
  • Use an instance variable if there are multiple of them. Call it "hidden" and make it a boolean or whatever you want, then do whatever you do to decide when the enemy hides, and make hidden true at the same time.

    You can then say:

    > if hidden = true
         enemy: set collisions disabled
    else
         enemy: set collisions enabled
    [/code:1r3odram]
    

    Thanks! I'll give it a try!

  • You can use "Is visible", or "Compare opacity", depending on how you make it invisible.

  • You can use "Is visible", or "Compare opacity", depending on how you make it invisible.

    I'm using different fade behaviours to make him come in and out of view, but when all of the fading is done and everything resets, he is invisible when fading out again. I checked the debugger, and it says that the fade-In behaviour is still in the fade-out stage, even though I set it to zero. Any ideas on how to fix this?

  • I'd have to see an example.

  • I'd have to see an example.

    Took me a while, but here you go.

    https://www.dropbox.com/s/m2witzr2nv9sz ... .capx?dl=0

  • This seems extremely complicated. Can you explain what you want? I get the general idea, but specifically, how should this work?

  • This seems extremely complicated. Can you explain what you want? I get the general idea, but specifically, how should this work?

    When you get in his line of sight, He fades away, gets right behind you and fades back in and attacks. After that he fades back out, goes back to where he started, then fades back in. The only problem is that once the whole cycle starts again, he stays invisible after he fades out.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > This seems extremely complicated. Can you explain what you want? I get the general idea, but specifically, how should this work?

    >

    When you get in his line of sight, He fades away, gets right behind you and fades back in and attacks. After that he fades back out, goes back to where he started, then fades back in. The only problem is that once the whole cycle starts again, he stays invisible after he fades out.

    i didnt opened your capx, but here is my own version of unexpected behavior AI

    the AI is by default patrolling, then the last move=4 is what is triggering the unexpected fade out/in and action (whenever the player enters the enemy distance of patrolling by 100 pixels then AI spots him and unexpectedly stabs him in the back.

    then if your player wold have something like a bullet shot at it, you wold compare if enemy.move<4 or not equal with 4 then trigger your usual life lose on enemy, else miss.

    however the code is getting stuck not sure why, ATM but as a example should do the trick so you can understand how you can use proximity and visual effect with opacity.

  • Here's a different approach. Uses a state-machine rather than a bunch of booleans, uses timers, has a single Fade behaviour, calls "restart fade" rather than start fade (that seems to be the real trick). I think part of the problem may be too many conflicting Fade behaviours. This did end up a bit complicated too, but the advantage is you can cancel any state, should you need to - something you can't do with Wait.

    http://www.blackhornettechnologies.com/Construct2Stuff/FadeEnemyCopy.capx

  • Here's a different approach. Uses a state-machine rather than a bunch of booleans, uses timers, has a single Fade behaviour, calls "restart fade" rather than start fade (that seems to be the real trick). I think part of the problem may be too many conflicting Fade behaviours. This did end up a bit complicated too, but the advantage is you can cancel any state, should you need to - something you can't do with Wait.

    http://www.blackhornettechnologies.com/Construct2Stuff/FadeEnemyCopy.capx

    You've really helped me a ton! Once my game is complete, I'm gonna put your name in the Special Thanks portion of my credits. Thank you so much, blackhornet.

    I'll check back with you if I have anymore issues/questions.

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