- Home /
Collision detection without effects and without triggers
I have a tank which can fall into water and I want it to have water splash effect. For this I need to get contact points of the collision between water and the tank which I could get from OnCollisionEnter function but at the same time I don't want the tank to have a collision effects. So how can I have collision-detection without collision effects?
Why don't you want to put a trigger on the water surface?
Whether trigger calls OnCollisionEnter? I need to get contact points.
Answer by Darkforge317 · Nov 29, 2017 at 06:28 PM
If you want the contact point of the tank on your water, just make a very short raycast downwards that will only hit the water (use either a layer mask or just check the tag of the object hit). Make sure this raycast has a RaycastHit variable passed into it.
Since you don't want the splash effect to be ON the tank then you need to create an empty game object that has a particle system component on it. Make the particle system the way you want to.
Now, Everytime you check if your raycast hit something, make sure it's the water. You can make sure by checking if the RaycasthitVariable.transform.tag == "Water" for example.
Once you verify it is water, you instantiate your particle system at the RaycasthitVariable.point
I would write code for you but I am currently on mobile and that would be a horrible experience.