Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: grimmy on April 06, 2013, 06:33:06 PM

Title: How can I do math on variables?
Post by: grimmy on April 06, 2013, 06:33:06 PM
For example, I want  100 sprites placing in a nice line. How do I set an object to be positioned at a variable + or - an amount or with any math for that matter..eg:

HalfTheEggs=AllTheEggs/2
BigMoveAMount=NormalMoveAmount*5

..etc..

Basically I can see how to input variables but do I need to create new variables for every part of the equation?
Title: Re: How can I do math on variables?
Post by: Alex Chouls on April 06, 2013, 06:37:37 PM
You need to use a loop. E.g., loop through a state that places a new sprite adding an offset to a spawnPosition variable each time.

Checkout PlayMakerSamples\TestLab\Spawning\SpawnGrid for an example. That sample uses a delay between each spawn, but you can set that to 0 to spawn all the objects in a single frame.
Title: Re: How can I do math on variables?
Post by: grimmy on April 06, 2013, 06:58:12 PM
Okay, but is there a way to use variables with math in an action? ..or do I have to create a new variable for each of the following instances?

Eg
ACTION:GUI Horizontal Slider 1 PARAM:Left Value VAR: Slider Position
ACTION:GUI Horizontal Slider 2 PARAM:Left Value VAR: Slider Position * 2
ACTION:GUI Horizontal Slider 3 PARAM:Left Value VAR: Slider Position * 3
Title: Re: How can I do math on variables?
Post by: jeanfabre on May 14, 2013, 04:16:49 AM
Hi

You might have to have one variable for each yes, especially if you want to use them differently in the end. IF it is just to reach a final variable, then you can reuse variable until you reach the final value.

bye,

 Jean