playMaker

Author Topic: Spawn Object if bigger than value...[SOLVED]  (Read 1556 times)

Tobeee

  • Playmaker Newbie
  • *
  • Posts: 13
    • View Profile
Spawn Object if bigger than value...[SOLVED]
« on: December 17, 2012, 06:24:37 PM »
Hi guys,

I have a global variable which defines the speed of my character. I want to tell Playmaker that when my speed is bigger than "1" unity has to spawn an object every "n" seconds. How do I do that?

BR Tobeee
« Last Edit: December 21, 2012, 02:02:49 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14052
  • Official Playmaker Support
    • View Profile
Re: Spawn Object if bigger than value...
« Reply #1 on: December 18, 2012, 01:15:41 AM »
Hi,

 ok, it's pretty simple :)

You have one state that watch the speed and triggers a transition is above 1, on the state you transited to, you watch for the speed and if it goes below 1 you transit back to the first state, meanwhile you also send event with a delay of 1 and transit ( or call a global event on another fsm) to spawn your objects.

 To check for speed value, use the action "float compare"

Does that make sense?

bye,

 Jean

Tobeee

  • Playmaker Newbie
  • *
  • Posts: 13
    • View Profile
Re: Spawn Object if bigger than value...
« Reply #2 on: December 18, 2012, 04:51:46 AM »
Hi Jean,
I think the compare action is what I'm looking for! I'll try it out.
Thank you!

Tobeee

  • Playmaker Newbie
  • *
  • Posts: 13
    • View Profile
Re: Spawn Object if bigger than value...
« Reply #3 on: December 20, 2012, 03:06:18 PM »
Hi,

float compare works, but I still have a problem. I want to spawn an object every second if the player is moving. So I created a state machine with a float compare which checks for the speed variable, if its greater than 0.1 it sends a transition to a state where the game object will be created. On this state I also have a wait action which waits for one second and after that brings me back to the first state where the variable is checked again. The strange thing is that it works but only twice.

Float compare -> Create object -> Float compare -> Create object (than remains on that state)

Any idea what this is? Could it be that its because the value of the variable doesn't change?

Thank you!

Tobeee

  • Playmaker Newbie
  • *
  • Posts: 13
    • View Profile
Re: Spawn Object if bigger than value...
« Reply #4 on: December 20, 2012, 03:24:44 PM »
I just solved the problem. I didn't use the FINISHED event on the wait state.