Hello Guest

Author Topic: Custom Box Collider  (Read 4178 times)

BTS

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 64
    • View Profile
Custom Box Collider
« on: August 11, 2013, 06:13:16 pm »
Hey there.

Working with the latest 2DToolkit Version in the AssetStore.

So I used the Custom Box Collider Feature in the SpriteCollection Editor on certain Sprites (Sprites which are used in the Attack-Animation).
Now I want to use this for handling collision via Trigger.
The thing is: that Collider is now enabled ALL the time and not only when the Animation is played. Is there a way via the editor to disable that or do I have to script that?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Custom Box Collider
« Reply #1 on: August 11, 2013, 06:23:31 pm »
You shouldn't really disable and enable colliders in Unity (or really any physics engine for that matter). You can still do it if you want, if you set your other sprites collider type to None / Force None - that won't destroy the collider but rather simply moves it away into some distant point to avoid things going wrong.

There are much better ways of doing this, eg. leave the collider attached all the time as a trigger, but when you need to, set/unset a flag to say whether to ignore the collision. Its much more efficient like that as well.

BTS

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 64
    • View Profile
Re: Custom Box Collider
« Reply #2 on: August 11, 2013, 06:48:30 pm »
Ah, thanks for the clarification. So, I'm using PlayMaker and I used the Set Property-Action on the Rigidbody which I attached to the sprite (set to kinematic in order to not mess up the PlatformController) and set the bool value of DetectCollision to false and it worked!
This way it's more efficient than disabling/enabling the Collider, isn't it?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Custom Box Collider
« Reply #3 on: August 11, 2013, 07:50:43 pm »
Yup that should be more efficient. I was going to remind you to add a kinematic rigidbody but you've got that sorted too from the looks of it :)