- Home /
Get position of collision with triggers?
Hey,
I have objects which explode on collision. So it's sufficient to have triggers as colliders. Which is inevitable anyway, because any other type of collider causes a lag when the object gets activated.
The problem now is, that the explosion particle effects have to be triggered at the position the collision has happened. But within the OnTriggerEnter method I only have a Collider object, which doesn't hold the position of the "access".
How can I get the explosion effect at the right position with triggers?
have your explosion particle effects on an empty object, and on the collision pass the transform info from the thing that collided to the particle object and then BOO$$anonymous$$ it.
"transform info from the thing that collided" unfortunately is not the position where the collision has happened. Usually I would get that information from a Collision object, but as I said, you don't have that information with a trigger.
@$$anonymous$$cGravity yeah, had a brain fart, it'll explode from the middle of the object that came in.
Answer by richyrich · Nov 27, 2014 at 01:05 PM
What shape are these shapes? If they are spheres/sphere-like, you could just measure the distance between the transform centres (some pre-calculation might be required). With the distance you could divide by two for the collision point or, if they were of different sizes, the collision point would be based on some calculation that took into consideration the approximate distance to edge.
Whatever you do, don't feel you have to be limited to just using the data the engine provides you with.