playMaker

Author Topic: Float Compare Time Wait  (Read 3299 times)

ergin

  • Junior Playmaker
  • **
  • Posts: 86
Float Compare Time Wait
« on: June 09, 2016, 11:30:44 AM »
Compares two float values with given interval, instead of comparing them on everyframe. This way you can control if certain conditions are met n times per second. Normally a condition need to be checked 60 times if made with everyframe(OnUpdate). With this action you can check it any times per second,(Coroutine) reducing CPU cost.

https://github.com/ergin3d/PlayMakerCustomActions_U5/blob/master/Assets/PlayMaker-Custom-Actions/Logic/FloatCompareTimeWait.cs

Thanks.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Float Compare Time Wait
« Reply #1 on: June 09, 2016, 07:06:57 PM »
Hi,
Actually you can easy loop that with adding a wait Action.

You can loop back to the same state btw, many peeps don't know that yet :)

ergin

  • Junior Playmaker
  • **
  • Posts: 86
Re: Float Compare Time Wait
« Reply #2 on: June 09, 2016, 08:16:50 PM »
Thanks, Actually I was doing it that way. I had noticeable performance improvement.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Float Compare Time Wait
« Reply #3 on: June 10, 2016, 07:48:39 AM »
Hi,
You had improvement with your action or with looping?

ergin

  • Junior Playmaker
  • **
  • Posts: 86
Re: Float Compare Time Wait
« Reply #4 on: June 10, 2016, 10:59:42 AM »
I think the wait loop combined with distance based (float) comparing was slowing down...

I made a test with 500 game objects with wait loop that run alone in one scene and in another scene 500 game objects with this action.

scene1: FSM: compare float --> wait 0.1 --> go back to compare float (500 instance) Wait loop:
33ms(30fps) when flowing
66ms(15fps) when spike
cpu: 35.14ms

This Action - Scene 2: compare float every 0.1 -> compare another float every 0.1 (500 instance)
16 ms(60 fps) when flowing
33 ms(30 fps) when spike
cpu 26.12ms

But this shouldn't be noticeable with single loop, I am making a lot of changes in my game very probably performance improvement is caused by another optimization.

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Float Compare Time Wait
« Reply #5 on: June 11, 2016, 04:48:16 AM »
Wow major difference.. Are you sure about the numbers.. Can anybody confirm?