playMaker

Author Topic: [SOLVED] switching states based on variables  (Read 1285 times)

trsnell

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
    • Portfolio
[SOLVED] switching states based on variables
« on: March 17, 2012, 06:55:50 PM »
I'm trying to use playmaker to create footstep sounds for my first person controller, which is a javascript. I managed to do it using get buttons, but that of course causes issues when strafing and moving forward or back at the same time. So I want to do it by checking the speed of the character controller.
Right now I'm storing the velocity of the first person controller using the Store Magnitude in the Get Axis Vector action (that's what it should do, right? I read it somewhere on here), but I can't figure out how to actually use that variable.
So basically, I want to do "if velocity is greater than X, switch to run state". Not sure if I'm thinking about it the wrong way, or if I'm just missing something.
« Last Edit: March 18, 2012, 01:57:52 AM by trsnell »

justifun

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 228
    • View Profile
Re: switching states based on variables
« Reply #1 on: March 17, 2012, 09:47:07 PM »
Storing the Magnitude will only help you in your situation by letting you know if the player is receiving any sort of input or not. (sounds like you could still do it this way, but you are leaning more towards wanted the actual current movement speed of your character).

A new action that jean wrote that would be perfect for this situation would be this one

GetObjectSpeed
http://hutonggames.com/playmakerforum/index.php?topic=1182.0

Download it and copy it into your "actions" folder in the playmaker one of your current project

You should now be able to find it in the action list

Save this speed of your player object into a variable (float i believe)

then use a "float compare" to trigger different event switches depending on if it equals or is less than or greater than whatever numbers you want to use.

make sure you check "every frame" on getobjectspeed (if im guessing you are using the way i think you are)

hope that helps!

trsnell

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
    • Portfolio
Re: switching states based on variables
« Reply #2 on: March 18, 2012, 01:42:47 AM »
Ah, thanks much! Float compare is exactly what I was looking for! Dunno how I missed it.. And yeah I think I needed Get Object Speed.
Gotta love scripting.. just spent a long time try to get it to work, then finally decided to restart from scratch and got it working right away with a really simple set up.

Now I just need to figure out how to have it change for running, which I'm not sure where to even start with..

edit: Nevermind, just got it to work. Thanks again, justifun!
« Last Edit: March 18, 2012, 08:39:13 PM by trsnell »