How do I do a smooth flickering light source

  • Using the LIGHTING example that comes with C2 I've managed to create a flickering lightsource around my player (top-down view) by randomly setting the scale of the light sprite "random(0.9,1.1)", which works, but the lighted area 'jumps' as the scale changes. Is there a way to scale smoothly instead of just jumping from one scale size to another?

    You can see what I mean here: http://www.madladdesigns.co.uk/relmquest - use cursor / arrow keys to move.

  • There are a lot of ways you could do this. A couple are as follows:

    1 - Use the lerp function to adjust the size of the sprite between it's current size and it's new size. This will create an ease in effect meaning the size change will slow down is it nears the target size.

    2 - Simply adjust the size by an increment when the current size and new size are different. This will create a linear change meaning the image will scale at a constant speed.

    See the attached capx for an example of both these methods. Of course both are very simple and need some tweaking to get a natural looking flicker but they should at least get you to a starting point.

  • Try Construct 3

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

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

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