playMaker

Author Topic: Changing the everyframe option on scripts. Is it even necessary?  (Read 1326 times)

precisionclear

  • Playmaker Newbie
  • *
  • Posts: 22
    • View Profile
Experimenting with frame rates lately and was suprised at how cheap raycasts can be, while spawning prefabs and running even simple "update every frame" actions can cause massive spikes + overall hits to performance.

An FSM with 2 "Get FSM State" actions set to "Update Every Frame", multiplied by about 60, 75 FPS dropped to 30 - not certain if these are more expensive then any of the more typical, "Get FSM Variable" actions. Discovered them recently and  personally find it more convenient than relying on sending events. Though "Starting" / "Resuming" / and "Stopping" would probably be even better for dealing with AI Logic, especially.

A reasonable intelligent and aware NPC with sight, path finding, and diverse range of reactions, soon finds itself keeping tracks of a large number of variables on /update.

Roughly speaking; 10 NPC's in any given area of 50 meters, could easily create similar conditions to my original test.

Seems that "Update Every Frame" is rarely necessary, as delayed reactions  make an Entity seem more humanlike. Would there be a way to slow updates down to 5,10, or even once every 30 frames based on the entire fsm tree iteslf? The Experimental feature updates Manually, but wouldn't that add a lot of overhead via sending out events.
« Last Edit: April 01, 2017, 04:46:04 PM by precisionclear »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13308
  • Official Playmaker Support
    • View Profile
Re: Changing the everyframe option on scripts. Is it even necessary?
« Reply #1 on: April 03, 2017, 04:55:05 AM »
Hi,

 this will be dependant on your gameplay, there is no rule for this, apart from making sure indeed that your feature stays performant.

 Bye,

 Jean

4ppleseed

  • Full Member
  • ***
  • Posts: 227
    • View Profile
Re: Changing the everyframe option on scripts. Is it even necessary?
« Reply #2 on: April 03, 2017, 06:12:17 AM »
Rather than using Every Frame I often just use a Wait loop for this and tweak the time variable up and down until it's tuned to the right feel.

Quite often with AI, having a wait for around 0.8 to 1.2 seconds feels pretty good and responsive. And that's a saving of 100 or so frames every loop.