playMaker

Author Topic: Instanced objects won't send collision events  (Read 1560 times)

homeworld

  • Playmaker Newbie
  • *
  • Posts: 39
Instanced objects won't send collision events
« on: July 18, 2018, 11:45:05 AM »
Hi! I'm making a level generator, and every time the player opens a door, a FSM spawns a new room from an array on the fly, and connects it to that door.

I've gotten the positioning and rotating of the rooms to work just fine, BUT since there's no logic to determine if the new room actually fits, i've added a trigger collision check once the new room is in the correct position, to ensure it doesn't overlap with some other room existing in that location.

This is where my problem shows up: all the rooms have kinematic rigidbodies,  they're all on the same tag, and the trigger event is set to look for that tag, but i can't get the newly instanced room to detect a trigger collision reliably.

I've tried within the same frame, as well as waiting a frame until the collision check, and i've also tried permutations of 'enter' as well as 'stay'. The only scenario where i had success was sending an event with a 1 second delay, and even that fails most of the time.

I've wasted hours and hours on this, and i can't imagine what's stopping my
colliders from triggering. Help would be greatly appreciated!

Plancksize

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 75
Re: Instanced objects won't send collision events
« Reply #1 on: July 18, 2018, 02:47:58 PM »
The answer for that is in Unity itself.
Your problem there is that you're trying to collide two kinematic rigidbodies.
A kinematic rigidbody will only colide with a non-kinematic Rigidbody collider.

Check the Collision action matrix at the bottom of that linked page.
https://docs.unity3d.com/Manual/CollidersOverview.html

That should give you a solution for your issue. :)

homeworld

  • Playmaker Newbie
  • *
  • Posts: 39
Re: Instanced objects won't send collision events
« Reply #2 on: July 18, 2018, 04:44:02 PM »
Hi, thanks for reading!! I did stumble across that chart while researching the problem, but unfortunately, my situation is overlapping kinematic rigidbody trigger colliders, which should have technically worked just fine; i'm still looking for a fix, let me know of any further ideas!

homeworld

  • Playmaker Newbie
  • *
  • Posts: 39
Re: Instanced objects won't send collision events
« Reply #3 on: July 18, 2018, 07:47:05 PM »
I ended up patching it up by giving each spawned room its own fsm that checks collision, and sends an event to the level generator, in order to spawn a different room that will fit better. This was also a very fiddly process considering i'm using multiple delays in order to get that coveted "trigger stay" detected.

I have no idea how the timing on these collision detections work after instantiating them, but i guess i got it working somehow for now!


Plancksize

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 75
Re: Instanced objects won't send collision events
« Reply #4 on: July 18, 2018, 08:13:44 PM »
Oh, sorry. I completely missed that you were using Trigger Colliders. Strange indeed then.
Just to make sure, i did try it (a couple of overlapping cubes with trigger collider and kinematic rigidbodies) and the "trigger event" action worked fine when activated the cube with the fsm. (almost clean project)

GL with finding a solution, and if you find what's causing that, please share it. I'm curious about the why.