Collisions detection fail

Firts of all, Hi because i’m new here

I’ve got problem with collision detection. I’m plaing with something like snooker game (stick - simple cylinder with ball).
A stick and the ball has rigidbody … move with a stick is controlled by mouse (forward and backward … at this time plaing with angles is not supported :slight_smile: ).
Here is what happens. When I move the stick to the ball very slow, collision works and the ball is moving, but when I do it quickly, the stick is going “through” the ball. I can’t do any of “quick shots”.
I’m coding with C# but only stick moves are scripted (4 or 3 lines of code, very simple)… and I’m wondering, is there any thing else needed to detect collisions like that ? I thought that all stuff with collision is done by Physics it self … but maybe I’m wrong.
I have read about ‘Is triggered’ option on object … maybe this way ?

Maybe this helps:

I would not use physics for a snooker game and instead code my own collision detection. My guess is you will get a ton of weird behavior if you use physics.

Not sure what the others in here think though.

There are enough cases where DontGoThroughThings doesn’t work that I wouldn’t try and make a game featuring a fast-moving ball in Unity unless I were writing my own collision and physics simulation for the ball. For snooker in particular, even an updated Physx might not be enough to support the kind of accuracy you probably want.

OK, so this is solution.

Second thing is to detect how much force is used to collision. I’ve got an example using smart solution … it counts per frame position (in this case stick posotion). On detection it counts avg from previous position and present position. Larger avg, larger force, larger vector.
Is that make sense ? Or maybe something else. I’m affraid that this “counting per frame” is not good for performance.

I think measuring the distance travelled per frame is a good way to get the speed of the cue and I wouldn’t expect this to have any real impact on performance. I think physics probably will work OK for a snooker game, but the cue passing through the ball is certainly a problem. Since you intend to get the cue’s position each frame anyway, I would suggest you use this to detect when the position of the cue’s tip is at or past the position of the ball and then use rigidbody.AddForceAtPosition to poke the ball at the contact point. The snooker balls should move more slowly than the cue and they are unlikely to pass through each other or through the cushions.

I found out a relativeVelocity function which has a linear velocity of two colling objects. I will try with this.