How do I make my player disappear after 3 seconds?

0 favourites
  • 3 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • hello. I'm working on my project and I want to make a function of, "if you stay still for 3 seconds, it will slowly hide, but if you move again, it will appear." I have tried everything, but it doesn't work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi TheMart,

    I just tried this on my project and it worked:

    This is only the hiding part, not the reappearing part, but if you understand it then you can figure out the rest yourself.

    Basically I check if the platform is not moving, if it isn't then I add to a variable I called TimeElapsed. I add dt - which is a variable that stands for delta time - the time that elapsed since the last frame.

    Then I check if TimeElapsed is already larger than 3, and if it is I remove 10% of opacity from the previous opacity value (of the animation object, not of the collision object - depends if you have these in two different objects or not).

    Let me know if that helped.

  • ilanfl You need to use dt for opacity too, otherwise the object will disappear/appear almost instantly, especially at high framerates.

    If Player is moving: 
    .. Set TimeElapsed to 0
    .. Obj set opacity to self.opacity+dt*100
    
    Else 
    .. Add dt to TimeElapsed 
    
    If TimeElapsed>3 
    .. Obj set opacity to self.opacity-dt*50
    
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)