When my player collides with an enemy I would like to allow the player to walk through the enemy (with flashing animation to indicate damage).
I thought that this would be best achieved by setting the collider of the enemy to a trigger. But… this is no good because OnTriggerEnter doesn’t appear to provide the contact points upon collision (which are essential).
If you can get away with it, temporarily disabling one collider by setting Collider.enabled to false would be simple.
Otherwise, you might try setting up collision layers and tweaking GameObject.layer on the player and/or enemy. You could temporarily put one character on a layer which doesn’t collide with other characters.
I didn't realise that you could switch between layers dynamically! Do you know if there are any performance issues related to switching between layers at runtime? Cheers
Not sure! It seems reasonable to assume there might be some physics complications, but they're probably fine if you're not doing this especially often.
I didn't realise that you could switch between layers dynamically! Do you know if there are any performance issues related to switching between layers at runtime? Cheers
– numberkruncherNot sure! It seems reasonable to assume there might be some physics complications, but they're probably fine if you're not doing this especially often.
– rutter