playMaker

Author Topic: Can you set Conditions to Trigger Events?  (Read 1434 times)

Grauen

  • Playmaker Newbie
  • *
  • Posts: 1
Can you set Conditions to Trigger Events?
« on: July 23, 2017, 09:47:24 AM »
I guess this is a really simple use case, but I couldn't find any examples for this use case. I want to build a simple rail shooter.

- I want the Camera to move to a gameobject I refer to as "waypoint"
- When the Camera reached the waypoint, I spawn enemies.
- The Camera stops moving.
- The Player has to shoot all enemies.
- If all Enemies are dead, the camera moves on to the next waypoint.

Moving to the position of an GameObject is easy with Playmaker.
It's also easy to activate GameObjects.

But how can you check if all currently active enemies are dead?
Is there a way to trigger an event, if a codintion becomes true? I'd be happy if you could provide some examples or show me the part of the Playmaker documentation which covers this case.

I also added a simple diagramm for this use case:

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: Can you set Conditions to Trigger Events?
« Reply #1 on: July 23, 2017, 12:09:12 PM »
Hi,

I think there is a simple solution.

Make a global int called 'enemy count' . In the enemy death FSM, subtract 1 from 'enemy count' when the enemy dies.

 In the same state that you spawn your enemies, add a 'set int' action and set the enemy count to however many enemies are spawned.

Then in the next state (in the spawn fsm) have an 'int compare' action. When the 'enemy count' global int variable equals '0', move to the next state which positions the camera at waypoint 2.

( Edit: also set every frame to on in the int compare action, if it even has that setting- i cant remember)

This is a simple way of doing it, using global variables, but it should work- Im sure there are more elegant ways of doing it, I just havnt used playmaker in a while and was browsing the forum out of boredom...
« Last Edit: July 23, 2017, 12:10:52 PM by Zeldag »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Can you set Conditions to Trigger Events?
« Reply #2 on: July 23, 2017, 12:29:29 PM »
Hi,
if it is a random spawn amount?
You can us an int add and add 1 for each enemy.
or you can place them into an array and when done you can get the array length

There are many different ways that you can do this btw :)