playMaker

Author Topic: Limiting Framerate  (Read 6673 times)

Avascar

  • Playmaker Newbie
  • *
  • Posts: 45
Limiting Framerate
« on: August 07, 2012, 10:00:35 AM »
How do I limit framerate?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Limiting Framerate
« Reply #1 on: August 07, 2012, 10:01:59 AM »
Hi,

 What's your goal or reason to limit frameRate? I am asking, because generally this should not be a problem.

bye,

 Jean

Avascar

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Limiting Framerate
« Reply #2 on: August 07, 2012, 10:47:39 AM »
Because the game goes over 200 FPS allowing me to go through walls and such and becomes quite buggy. I want to limit it to 60 FPS

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Limiting Framerate
« Reply #3 on: August 08, 2012, 05:50:04 AM »
hi,

 I don't think it's the frameRate that let's you go though walls, instead you should adjust the physics settings.

bye,

 Jean

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: Limiting Framerate
« Reply #4 on: August 28, 2012, 11:32:21 PM »
Hi, I was going through the posts and found this and thought this might be useful, I am looking to develop on a mobile platform and would like to limit the FPS to save battery on devices

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Limiting Framerate
« Reply #5 on: August 29, 2012, 02:28:41 AM »
Hi,

 try this:

http://docs.unity3d.com/Documentation/ScriptReference/Application-targetFrameRate.html

You also have a setting on the IOS Project in xcode to limit the framerate too, but I don't know how it works on android.

bye,

 Jean

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: Limiting Framerate
« Reply #6 on: June 13, 2014, 04:19:26 AM »
Using third party products such as 'Curvy: Fast Spline Interpolation' and Playmaker 'Speed' settings such as 'Checkmark do this every frame' is not syncing well together!

ATM I have the problem that throttle (divided by 1.01 every frame in Playmaker)   of my space ship (traveling with Curvy) is going down way too fast when frame rates are way too good!

Since so much in Playmaker is hooked up to 'Every Frame' I think a set of controls to work with this frame rate in Playmaker would be great!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Limiting Framerate
« Reply #7 on: June 13, 2014, 07:12:28 AM »
If you don't manually control the amount of time it takes to do something then the computer will systematically do it as fast as it possibly can. This is actually precisely why you have good framerate and optimization anyway.

http://unity3d.com/learn/tutorials/modules/beginner/scripting/update-and-fixedupdate

You can use FixedUpdate for avoiding things like this. Math actions aren't going to be something you compute in FixedUpdate, for obvious reasons, so you need to identify issues like this and find a way in your design to control the rate of change.

In the 90's and early 00's this was a moderate issue i guess because no one expected computer speeds to move forward so fast.. so nowadays you need to get a wrapper that caps the framerate on the game so it isn't playing at lightspeed. I suppose there are uses for that today, but it can be avoided by design.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: Limiting Framerate
« Reply #8 on: June 13, 2014, 08:44:13 AM »
"You can use FixedUpdate for avoiding things like this"

Erhm.. erh.. Via scripting yes..

How would I do that in PlayMaker? (I can only think of making multiple separate FSM's that are paused in the loop by 'Wait' actions - is that what you mean?)

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: Limiting Framerate
« Reply #9 on: June 13, 2014, 08:47:52 AM »
Like, how would you do something like this with 'Fixed Update' - in Playmaker?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Limiting Framerate
« Reply #10 on: June 13, 2014, 08:55:26 AM »
What is speed driven by? Are you using physics? Get Axis?

Need to look at the system as a whole, solving an isolated case like that with some solution might not be the best way to deal with something, maybe there is a better way at a higher level.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: Limiting Framerate
« Reply #11 on: June 13, 2014, 09:04:14 AM »
Oh yes, there's alternatives :)

But when all comes to all, I can divide 'speed dependent things' in a Unity / Playmaker game up in 3:

A) Every frame - what most Playmaker actions rely on
B) Delta Time - what most 'third party' products (scripts) rely on

And A/B are not in sync, that is my point here

C) Then there's the various ways to 'do something about this'.

I'd just like to point out that Playmaker could IMO take this much better into account, and so eliminating C) in the very typical case shown above, where 'Speed' is used to drive a third party Spline-move-along.

If Playmaker had instead of only 'Every Frame' a from of 'Fixed update' in all the standard actions, then there would be no need for C).

I could just mark 'Fixed Update' instead of 'Every frame' and that would be the end of those trouble!

What I am asking you is which C) are you suggesting?

Since there's no clear answer, I presume it is because there's no 'clean solution', and I'll just make strange sub-FSM's that do their own loop-pausing based on time.

thanks.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Limiting Framerate
« Reply #12 on: June 13, 2014, 09:11:19 AM »
Some actions (where its applicable) have a Per Second checkbox for that purpose. Backing up and looking at a different approach to the problem is a good way forward here, rather than trying to fix a situation with brute force.

I do like the idea of having that, but at the moment it would require a large rework of all actions so good thoughts for future versions perhaps but not something we could use to resolve on a large scale now.
« Last Edit: June 13, 2014, 09:13:27 AM by Lane »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: Limiting Framerate
« Reply #13 on: June 13, 2014, 09:19:02 AM »
Lol thanks for being persistent, but what other solutions could there be?

IMO the example is as simple as it can be: A Space ship is moving on a spline with a third party system. The speed is set via Playmaker. Speed should be 100 at least, but can be boosted up by 'power pills'.

So, Float Speed need to be reduced constantly in Playmaker, like shown in the screen dumps above.

This cannot be done in any other way than a form of ugly 'Brute force' with Playmaker, can it?

So I think it'd be VERY applicable if a standard PM Action like those shown would have a 'pr second' option as well as a 'pr frame'. Would it not?

THis is just a small example, but look at all syncing with animations etc.. It cannot be done with PlayMaker in any other way than 'brute force', can it? No :)


***
Edit: Oh, this is unfair you changed your post - so the above does not make that much sense now - but at least we now agree :) And I'll have to 'brute force' and so be it :)
« Last Edit: June 13, 2014, 09:20:53 AM by FritsLyn »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Limiting Framerate
« Reply #14 on: June 13, 2014, 09:22:26 AM »
IMO the example is as simple as it can be: A Space ship is moving on a spline with a third party system. The speed is set via Playmaker. Speed should be 100 at least, but can be boosted up by 'power pills'.

Couldn't you just use Float Subtract with Per Second instead?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D