playMaker

Author Topic: CollisionEvent not working on prefabs with more than one collider?  (Read 3830 times)

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
I'm not sure if I'm somehow using this wrong or if it's a bug with either Playmaker or Unity, so here goes:

If I have a prefab with an FSM that contains the CollisionEvent action, it works fine on detecting collisions on other prefabs that have only one collider, but if there's another collider anywhere in the hierarchy, whether that second collider can be touched or not, the CollisionEvent completely stops working.

For example:
I created a prefab that was just a cube with a collider and rigid body (This was my "target") and placed it in a scene. I've got a projectile that is just a sphere, again with a collider and rigid body. The projectile is identified with the tag "Bullet". The target has an FSM with the CollisionEvent action in the start state set up with the default "On Collision Enter", "Collide Tag" set to Bullet, and "Store Collider" set to a GameObject variable.

If I shoot the projectile at the target, it works perfectly: The Bullet tag is detected, the Projectile name is stored in the variable, and the Send Event is triggered.

If I now add a child game object to the projectile and put a collider on it, any size, any kind, and even reduce it's size to almost zero so there's no way it can be hitting anything because of the much larger Main collision, the CollisionEvent on the target stops working entirely: the event doesn't fire and nothing shows up in the Store Collider debug field. All objects are left on the "default" layer, so no funny business there.

What makes me think this is some kind of issue with Playmaker, is that if I put the following javascript on the target:

Code: [Select]
function OnCollisionEnter (hit:Collision)
{
Debug.Log ("Puck hit: " + hit.gameObject.tag);
}

I get a debug that works every time. The collision is always detected and the right tag returned. It doesn't matter how many colliders on children I have, it just works.

What makes it even more interesting is that if, on the target, I get rid of the CollisionEvent and instead make a new state, right-click on it, and choose "Add Global Transition > System Events > Collision Enter", and then add a GetCollisionInfo action, I can use the "GameObjectHit" option to return the name of the object and then use GameObjectCompareTag to trigger the event I want. This method works just fine, but isn't possible to use in a lot of situations.

Any thoughts?

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
Re: CollisionEvent not working on prefabs with more than one collider?
« Reply #1 on: June 14, 2013, 10:44:17 PM »
Update: since I've gotten no response on this, I've gone ahead and made it an official bug with the bug reporting tool in the editor.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: CollisionEvent not working on prefabs with more than one collider?
« Reply #2 on: June 15, 2013, 12:38:47 PM »
Thanks, I'll look into it...