playMaker

Author Topic: How to code an object breaking in Playmaker?  (Read 1003 times)

alextm2997

  • Playmaker Newbie
  • *
  • Posts: 3
How to code an object breaking in Playmaker?
« on: July 28, 2020, 02:59:28 PM »
For my 2D RPG game, I'm trying to figure out the simplest way of coding a pot to break after the player attacks it by releasing an invisible hitbox so the pot can detect the hit.

The player's hit boxes all have 2D polygon colliders and they appear during the player's attack animations.

In Playmaker, the Pot's FSM has an Idle state where if a Collision2D event occurs with an object with the tag "Hitbox", it should send the event "Smash" and go to the "Destroy" state.

The Destroy state includes "Destroy Self". I'll add animation later, but I first want to see how it will look when it's destroyed instantly.

The problem is, when the player attacks the pot, nothing happens. The Pot's FSM never goes to the "Destroy" state.

I tried adding "RigidBody2D" (Dynamic with gravity scale at 0) to all the Hit boxes and marked the pot as a trigger in 'Box Collider 2D', but still no luck.

How come the code isn't working? Any help would be appreciated.

Thanks.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How to code an object breaking in Playmaker?
« Reply #1 on: July 28, 2020, 04:37:23 PM »
Hi.
Probably it will be better to use 'trigger events'.

If you attack collider is set as trigger it will not detect collision. (trigger can not collide)
and you attack colliders should probably be set as trigger (if they are not)