- Home /
Cloth collision detection?
Hi all,
I am trying to build a system where I can throw a cloth ball (looking like a ball of gloop) at an object, e.g. the ground, and spawn a splatter texture where it hit.
As far as scripting is concerned, how do I detect where and when the cloth object collides? When the cloth simulates the gameobject's position stays in the same place, although the mesh falls. Also I would like to spawn the cloth ball with an initial velocity - the documentation for InteractiveCloth.AddForceAtPosition isn't great - how do you specify direction?
Any help appreciated, Simon.
O$$anonymous$$, I think I've solved it.
I'm getting the centre of the mesh by using renderer.bounds.centre, and have a seperate sphere collider which has that as its position.
Edit: Having trouble getting OnTriggerEnter to be called. I'm going to try detecting a collision myself by looking at the speed of the collider.
Speed detection isn't working :(
OnTriggerEnter wasn't being called because the plane didn't have a rigidbody attached.
I realise I've got a bit off-topic here, but the rigidbody doesn't like the fact the plane has no depth. In the final game it will most likely be a terrain - would OnTriggerEnter work for that?
Fixed (for real this time)
OnTriggerEnter wasn't being called because the plane wasn't moving, and the physics wasnt checking it or something. By puttin the rigidbody on my glob collider object ins$$anonymous$$d, OnTriggerEnter is called properly.
Bleh.
Your answer
![](https://koobas.hobune.stream/wayback/20220613061928im_/https://answers.unity.com/themes/thub/images/avi.jpg)