playMaker

Author Topic: Collision detection stops working after re-activating a chtr controller![SOLVED]  (Read 4211 times)

XilenceX

  • Playmaker Newbie
  • *
  • Posts: 11
hi,
I've got an urgent problem that should be pretty easy to reproduce.
1. Create a capsule, remove its collider and add a character controller instead.
2. Create a sphere with a sphere collider AND rigidbody and shoot it into the capsule by adding force to it via Playmaker.
3. Add an On Collision Enter Collision Event to the capsule that sends out an event.

Now if you play that game the collision should get detected as expected. However if you deactivate the character controller/capsule in-game either via a playmaker action or simply by deactivating its checkbox in the inspector, and then re-activate it no collisions will be detected anymore!

This essentially makes the enemies in my game  immortal if I deactivate and then re-activate them for performance optimization. So... help!  :o
« Last Edit: December 07, 2013, 03:31:23 AM by jeanfabre »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Why do you need the Character Controller?

The Character Controller will come with its own Collider but the Rigidbody component doesn't recognize it. The Character Controller works with transforms while the Rigidbody works with physics and the two do not play well together (at all), generally you should choose one method or the other unless you are sure the results will be consistent and work as intended. For instance using rotation transforms on top of a physics driven agent.

I can't reproduce your deactivate/activate trigger issue, it seems to work fine no matter how hard I try to break it. The problem is likely something breaking down in your components between the CC and RB.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

XilenceX

  • Playmaker Newbie
  • *
  • Posts: 11
hmm ok I've recorded a video to show you how you can reproduce the problem. Perhaps I've forgotten to mention something?
I'll post it here when the upload is finished.
Here is a picture of the inspector of the projectile (fireball) that hits the capsule, as I forgot to show it in the video:
« Last Edit: December 04, 2013, 11:02:20 AM by XilenceX »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Sounds like you need another larger Collider [Trigger] on the capsule that is used to detect collisions. The character controller isn't going to do that.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Heres my test scene. Take a look.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

XilenceX

  • Playmaker Newbie
  • *
  • Posts: 11
ok here is the video as promised:

As you can see the character collider handles the collision check event just fine, but only BEFORE it gets deactivated and reactivated.

Your test scene uses a trigger event, which doesn't really have anything to do with the collision problem at hand. I set up the 20ish enemies in my game many weeks ago with the collision check events, i am not sure anymore why I chose this solution instead of triggers, but IIRC it was for a good reason. I believe the triggers may not have been precise enough. Either way I am not going to set them all up with a system based arround triggers, now that the game is about to go into beta. heh

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Ah ok I used a trigger, my mistake. Used a collision setup and was able to repoduce it.

It appears that this is a problem with the Character Controller component, but there is a chance that it may be the action failing to recognize the component being respawned, but I seriously doubt it. The best way to circumvent it is to add another Collider Component the same size as the character controller one and the fact that it works every time after that leads me to believe that it is a problem with the Character Controller rather than the collision system or PlayMaker.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

XilenceX

  • Playmaker Newbie
  • *
  • Posts: 11
Awesome adding a capsule collider of the SAME SIZE fixes this problem both in the test scene and on my actual enemies. Fun fact I had the same idea yesterday and it didn't work out for me, because the collider wasn't the same size as the character controller the enemy had.
So thanks for helping me solve this problem!  ;D