Playmaker Forum

PlayMaker Help & Tips => iOS Help => Topic started by: jayhfd on March 26, 2012, 10:14:01 PM

Title: How "expensive" is Sample Curve
Post by: jayhfd on March 26, 2012, 10:14:01 PM
Hi,
I'm using a ton of Sample Curve actions for all sorts of things. Mainly converting one number to another useable number. Ie converting my player's speed (50-100) into an audio pitch or volume variable (0-1).

My question is, how expensive are they to use, and is there a cheaper way to do this? I'm rather terrible with anything logic or math based, so there could be a much better way! I'm targeting 3gs and higher ios devices, and currently getting reasonable speed from my game (3ms/frame) but I just wanted to make sure!

Having asked this, I'd be curious to know how expensive many actions are to run. I'm not sure if there's really any kind of documentation for that?

Cheers,
Jay
Title: Re: How "expensive" is Sample Curve
Post by: jeanfabre on March 27, 2012, 01:20:59 AM
Hi,

 The most expensive things in real time engines are rendering the meshes ( texture, materials, etc etc). Physics also can be a killer. So don't worry too much about using animation curve, Script in general is rarely not the bottle neck of an application.

Having said that, there are few known things to be avoided with scripting:

-- don't find gameObjects in the game loop. The game loop is code that is performed every frame or more than one time per frame. Finding gameObject takes time, so cache or reference your gameObjects in variable and use the variable.

-- adding components and removing components also can create hickups.

Most experienced developer on their talk tell us that optimization should be done after you have your game working. So make your game, make it work, then see how it performs, you can always improve then. This is better then trying to find the optimal way of doing something that you don't even know the full implication in your game... a mistake I did many times... the code ended up in the bin ( but it was very efficient.... conclusion: waisted my time...)

Also, Unity has a profiler window where you can really see where is the cost of things. So run your game with the profiler on, and you'll see where you stand between mesh, physics and scripts.

Bye,

 Jean
Title: Re: How "expensive" is Sample Curve
Post by: jayhfd on March 28, 2012, 05:14:17 AM
Thanks Jean, will keep this in mind. Good to know curves aren't slow, they're very useful to me.

Cheers!
Jay