playMaker

Author Topic: Destroy Self ?[SOLVED]  (Read 1419 times)

TVISARL

  • Junior Playmaker
  • **
  • Posts: 50
Destroy Self ?[SOLVED]
« 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.
« Last Edit: December 20, 2019, 03:06:20 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Destroy Self ?
« Reply #1 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

TVISARL

  • Junior Playmaker
  • **
  • Posts: 50
Re: Destroy Self ?
« Reply #2 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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Destroy Self ?
« Reply #3 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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Destroy Self ?
« Reply #4 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

TVISARL

  • Junior Playmaker
  • **
  • Posts: 50
Re: Destroy Self ?
« Reply #5 on: December 18, 2019, 01:18:43 AM »
Thanks, Jean. I'll try that.

TVISARL

  • Junior Playmaker
  • **
  • Posts: 50
Re: Destroy Self ?
« Reply #6 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.