Lose Collider triggering without collision occuring

HI I’ve had the same issue with colliders that others have had where the balls gravity calculation causes it to get past the paddle somehow, and then trigger the lose collider.

Both the solutions I have linked below work to solve the issue, I’m wondering which one is considered a best practice or more performant. I would love if someone from the GameDev team actually jumped in and maybe even updated the course since it is asked a lot. @Nina @Rob

All thoughts on the pros and con’s of each use case would be appreciated.

1 Like

Hi there and welcome to the community : )

Not a GameDev team member, but allow me to express my opinion. Yes, both solutions do work, however Rob’s answer is heavier (as also stated in Unity’s documentation), since the engine performs a continuous calculation, as opposed to Nina’s solution, where the magic happens only when “LaunchOnMouseClick()” gets called.

In general, try to use what suits your problem best. Do not use heavier operations when not necessary, try to simplify things.

Welcome to the community!

After seeing the threads I’m actually surprised it worked in both cases because they solve very different issues.

Nina’s solution prevents the ball from triggering the lose colliders when it hasn’t been launched.
Rob’s solution prevents the ball from going through objects.

Completely different stuff, one has the ball completely stopped, the other has it moving. Not sure what is going on here, but there’s no way to compare and determined which solution is better.

1 Like

You’re actually right about it, I thought both of them needed to ignore the collision on the platform haha

Hi @HypedOnCoffee,

Welcome to our community! :slight_smile:

The underlying problem is this: We manipulate the transform.position via code and override the calculated values of the physics engine. Since Unity’s physics simulation is highly optimised, it is likely that the position of the ball does not match the position of the collider anymore.

My solution is more performant than Rob’s because it removes the ball from the physics simulation as long as it is glued to the paddle. Each object in the physics simulation requires Unity to calculate things.

Rob solves the problem of the optimised collision detection, which can make colliders miss other collider in certain cases. His solution could also solve the current problem (see above) because a different mode could make the physics simulation check the position of the game object more often. This is, of course, less performant than removing the ball from the simulation.

If you ask another programmer, it might be that they will come up with a third solution. That’s not uncommon because, in many cases, there are multiple ways to get things done. Don’t get confused by different solutions for the same problem. Try to understand the ideas and opt for the one which you feel solves your problem best. Maybe you will even come up with your own solution. :slight_smile:

Did this help?


See also:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms