playMaker

Author Topic: Triggering an event after collecting X amount of items. [SOLVED]  (Read 2443 times)

intrikit

  • Full Member
  • ***
  • Posts: 132
    • Defiant Child
Hey guys,

I'm working on an activation mechanic after collecting a certain amount of a certain item. I know how to create an object after collecting one object, but what is the best way to create an object after collecting, say, five of the same objects?

Thanks in advance!
« Last Edit: August 25, 2014, 06:11:28 PM by intrikit »

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Triggering an event after collecting X amount of items.
« Reply #1 on: August 25, 2014, 09:12:12 AM »
instead of creating the object after collection, add a 1 to an Int variable (Int Add action). then simply check that Int when collecting an object to see if the Int = 5, then create your object.

So on your FSM, you'd have an Int Compare state before your Create Object state.

(Don't forget to reset your Int value to 0 after creating your object)

intrikit

  • Full Member
  • ***
  • Posts: 132
    • Defiant Child
Re: Triggering an event after collecting X amount of items.
« Reply #2 on: August 25, 2014, 04:40:46 PM »
Ah thanks! How do I reset the value back to 0 once the set number is collected?

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Triggering an event after collecting X amount of items.
« Reply #3 on: August 25, 2014, 04:43:04 PM »
You can either have the number as a global with a state that set fsm amount to 0 or using the same set FSM amount action to find the number in its FSM and set it to 0 directly.
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

intrikit

  • Full Member
  • ***
  • Posts: 132
    • Defiant Child
Re: Triggering an event after collecting X amount of items.
« Reply #4 on: August 25, 2014, 05:57:27 PM »
Ah this works! I just used a set FSM action after creating the object and looped it back to the start state.

An unrelated question now though. What is the best approach for this created prefab to follow the player around? Smooth Follow and Set Parent actions don't seem to allow this.

intrikit

  • Full Member
  • ***
  • Posts: 132
    • Defiant Child
Re: Triggering an event after collecting X amount of items.
« Reply #5 on: August 25, 2014, 06:11:04 PM »
Ah this works! I just used a set FSM action after creating the object and looped it back to the start state.

An unrelated question now though. What is the best approach for this created prefab to follow the player around? Smooth Follow and Set Parent actions don't seem to allow this.

Nevermind  :)