Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: TVISARL on December 16, 2019, 10:49:34 AM

Title: Destroy Self ?[SOLVED]
Post by: TVISARL on December 16, 2019, 10:49:34 AM
Hi, all !

In my game, the player gets to destroy Aliens by shooting them up ( I know, I know ).
The Aliens are all instances of a prehab created with an FSM that starts with a TRIGGER ENTER event ( the prefab has a collider, of course ) and just does one thing: Destroy Self when the Alien receives a bullet.

Yet they are destroyed in droves with a single bullet or a single collision with NavMesh Obstacles !

How come ? Thanks in advance.
Title: Re: Destroy Self ?
Post by: jeanfabre on December 17, 2019, 12:55:50 AM
Hi,

 Could be that you broadcast the even the lead to the destroy and so all your ennemies gets it.

How do you check for trigger enter?

Bye,

 Jean
Title: Re: Destroy Self ?
Post by: TVISARL on December 17, 2019, 08:15:30 AM
Thanks for your reply !

How do I detect "trigger enter" ? Like that.
The FSM is part of the prefab, and therefore all instances have it.

The "Got It" state has only one action: Destroy Self.
The "Step 1" state is concerned with the Alien as a NavMesh Agent. As such it has three actions : "Set Agent Destination As Game Object", "Agent Move' and "Look At" (the target).

Very, very simple. Too simple ?

Thanks for you help.
Title: Re: Destroy Self ?
Post by: djaydino on December 17, 2019, 11:59:26 PM
Hi.
Just a side note.
If your are instantiating and destroying multiple of these prefabs, you should look into pooling them also things like bullets etc if you have these in the game.
Title: Re: Destroy Self ?
Post by: jeanfabre on December 18, 2019, 12:40:56 AM
Hi,

your trigger enter will catch ANY triggers, so what you likely want is a more constraining trigger rule, using TriggerEvent Action and you filter by tag "player" so that only the player will trigger ennemy

Also, to debug your fsm as is and check what indeed triggerd the ennemy, simply use the action getTriggerInfo on the state coming from the trigger enter event and check which object it triggered, then you will get a better understanding of what's happening.

Bye,

 Jean
Title: Re: Destroy Self ?
Post by: TVISARL on December 18, 2019, 01:18:43 AM
Thanks, Jean. I'll try that.
Title: Re: Destroy Self ?
Post by: TVISARL on December 18, 2019, 05:23:20 AM
Yes. I had tried to filter the collisions with Edit/Project Settings/Physics, but I had forgotten something.
Anyway, the "Get Trigger Info" (I had forgotten it, there are so many of them !) provides a simple and easy solution.
So, problem solved. Thanks again.