0 favourites
  • 12 posts
  • I have an enemy with fade behavior and fade in/out both at 1 second. What I need to happen is the enemy starts out invisible, and when it is in the area of the player, it needs to fade into visibility. And then when it leaves the area of the player I want it to fade out. Not quite sure how to do this.

  • Use 2 fade behaviors for the same enemy. Fade1 fades in however long you want and "0" fade out (tell it to not destroy on fade out); Fade2 will have "0" fade in and however long you want it to fade out (tell it also to not destroy on fade out so that the same enemy is still moving around when it's invisible). Also make an empty sprite (no image, just a blank box) and link it to the enemy (look this up in a tutorial; the box will move with the sprite); make it as big as you want for however much space you want there to be between the player and the enemy when it appears.

    For events, when the enemy is "On collision with" the blank sprite, "Start Fade1"; when the enemy is not "On Collision with" (inverted) the blank sprite, "Start Fade2".

    If you are spawning enemies when they get in proximity with the player (which is probably what you should do to keep the game running smooth), then make sure you tell Fade2 to destroy on fade out (ignoring what I said above).

  • Thanks a lot! I don't have a computer available to use until tonorrow but reading through this it seems very logical. I was unaware you could have 2 fade behaviours so I was tryin to do it with 1 begavior that had a fade out and fade in time.

  • I just tried this out and I have one problem, since On Collision is a trigger it cannot be inverted.I have On Collision with the object it needs to fade into visibility, but once the player walks away it stays visible.

  • try inverting 'is overlapping' instead

  • Okay I'm starting to get somewhere, however if I use Is Not Overlapping, then it keeps repeating the fade out when not near the player. Whereas I need it to fade out and then stay invisible until it gets near the player again.

  • Oops, sorry about that. Damn, now I want to figure this out so I'm gonna have to do it.

  • I can get it to either fade out fine when not near but when it gets near it doesn't fade in, or get it to fade in fine when near but not fade out when the player moves away. Unfortunately I can't get both, still experimenting though!

  • I got it! The solution is to use the system "Trigger Once While True" Condition with the "Is Overlapping" event.

    Use the arrow keys to move the player around (straight down is where the enemy is).

    Here is the capx...


    *pats self on back*

  • One method, if you want it to fade in in relation to the player, is to set the opacity of the object depending on the distance between object and player.

    So, set object opacity to 100-(distance(player.x,player.y, object.x,object.y*0.1)) for example.

    This way its visibility will always be in relation to distance, instead of just fading all the way in or all the way out. Not sure if you want this, but just thought I'd give an idea :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Tobye

    I have the player carrying a lantern and when the "Shadow" enters the light of the lantern, it fades in to visibility, when the shadow is not in the light it fades out.

  • Thanks for figuring that out for me! Maybe I should try to be more observant, I have never noticed the trigger once condition.

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