playMaker

Author Topic: Looping states... for light flickering  (Read 5958 times)

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Looping states... for light flickering
« on: September 29, 2012, 09:05:03 AM »
Hi,

I have a Set light Intensity on start state and a random Float. The random float sets a Var, that is sent to the Light Intensity value of the Set Light thing.

But the random float thing, just does ONE random number then stops, how can I make the whole thing loop over and over...

...Or is this a bad way of doing a flickering light. (Its fire actually, when you get close)

Mark

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Looping states... for light flickering
« Reply #1 on: September 29, 2012, 10:14:28 AM »
It would seem pretty simple i think... once you're in your final state, use a "finished" transition and loop back to the state you want it to.

if you already have it set to loop and it's hanging, however, maybe consider dropping in a "next frame event" action set to use the "finished" (or whichever transition you're using to loop back.) it should fire off when the next frame is called... though if your last action is so action-heavy that it would take more than a frame to finish up all the actions, a next frame event might fire off too soon in which case a "wait" event would be more appropriate (same setup, tell it to call the "finished" transition once it's done.)

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Looping states... for light flickering
« Reply #2 on: September 29, 2012, 02:20:19 PM »
Excellent!!
Worked like a dream!

I have to say, that Im wondering if this is the right approach for such an effect. As soon as I started my game, the light flickered and the fan on my computer kicked in like the thing was gonna take off!!!

The FSM is whizzing around so fast Im wondering if it aint a CPU/memory hog, and there is maybe a more elegant way to do it?

That is, make a light flicker ina  pleasing manner, so that if casts a nice firelight glow onto our hearo as he approaches the fiery abyss of hell?

 :)

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Looping states... for light flickering
« Reply #3 on: September 29, 2012, 07:03:21 PM »
if it's firing off that quickly, might be worth considering adding in a bit of a waiting element to it... because if you have actions firing off, the infinite loop detection kinda doesn't trigger (which is because it technically isn't an infinite loop.)

try adding in the next frame event if you haven't... that should add in at least a small bit of a wait at the very latest (so it'll only fire off once a frame as opposed to as soon as it possibly can.)

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Looping states... for light flickering
« Reply #4 on: September 30, 2012, 02:47:37 AM »
Thanks Ill give it a go... doesnt seem to be much point in being FASTER than every frame right!! The visual effect looks nice tho! THX!


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Looping states... for light flickering
« Reply #5 on: October 01, 2012, 01:24:43 AM »
Hi,

 you simply need to use "send event" to loop back with a delay.

using framerate to flicker will give different results on different machines, so I do recommand that you set a delay in milliseconds so that the experience is consistent and predictable.

Else, you could use some noise function to change the light intensity, that would give a lot more "life" ro the flickering.

http://hutonggames.com/playmakerforum/index.php?topic=46.0


bye,

 Jean

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Looping states... for light flickering
« Reply #6 on: October 01, 2012, 02:06:15 AM »
Hi,

 you simply need to use "send event" to loop back with a delay.

using framerate to flicker will give different results on different machines, so I do recommand that you set a delay in milliseconds so that the experience is consistent and predictable.

Else, you could use some noise function to change the light intensity, that would give a lot more "life" ro the flickering.


I'm already getting the randomness Jean, by using the random float action, to create a LightLevel variable, that is then read by the setlight action. works nicely, but will introduce the delay as has been suggested.
:)