playMaker

Author Topic: What are variables and how do they work? [SOLVED]  (Read 1246 times)

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
What are variables and how do they work? [SOLVED]
« on: July 03, 2017, 04:54:09 PM »
Following on from my previous question 'What exactly does "Get Axis" do?', I wanted to ask another fundamental question from a beginner's point-of-view:

What exactly are variables and how do they work?

I have a vague understanding, but if anyone could explain in the clearest terms possible, it would really help.  A handy metaphor wouldn't go amiss!

Thanks all.
« Last Edit: July 04, 2017, 04:25:16 PM by ItzArranT »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: What are variables and how do they work?
« Reply #1 on: July 03, 2017, 08:44:40 PM »
Hi,

This tutorial will show you what "get axis" does but in script:


To try this in Playmaker you can make a cube and make an fsm on it.
Place a 'Get Axis' in the start state and use the multiplier to adjust the speed set it to 5 for example. and set 'Horizontal' as Axis Name.

Then in the variable tab, create a new variable and set the variable type to float.
and set this Variable in 'store' on the 'Get Axis' action.

A variable is like a container. you can place something in it (Value) to use somewhere else later on. The name of the variable is to know for what you are using this and the type is to know which kind of value is inside it.
for example a 'Int' variable can only have whole number in it (1,2,5,299)
A 'Float' variable can contain a fractional part (1.32, 2,76 , 53.34635)

In the same state also add the action 'Translate' and place it below 'Get Axis'
On 'X' place The variable that you made.
Be sure that 'Per Second' is checked and also 'Every Frame' is checked.

Now you can play your game, press left and right arrows to move your cube.

In the state tab on the bottom there is a checkbox called 'Debug' you can check this, then you can see what is going on with the variables in your actions.

Here you can find many tutorials to get you started.

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: What are variables and how do they work?
« Reply #2 on: July 04, 2017, 04:25:04 PM »
And yet another thanks djaydino!

I've been using Playmaker for about a month now, which I sort've just dived in to, so I'm taking the time to understand the fundamentals as clearly as I can.

Thanks again.