- Home /
What can I do about collisions that are not accurate enough?
I am basically doing a billiard shot. A ball is shot from a turret, collides with another ball, and bounces off. The problem is that I can adjust the turret angle by fractions of a degree and nothing changes with the bounce off of the colliding object. Eventually the turret moves enough that it hits a point where the bounce angle jumps by up to 45 degrees. Here is a video of me making micro changes to the turret angle and the collision eventually jumping by large amounts:
I want the user to get their bounced shot to land exactly where they want it. How can I make this shot more accurate? Is this possibly happening because the default sphere collider does not have enough faces on it? If so, is there a way to increase the number of faces or do I need to make a mesh collider and import the sphere model from another software?
Just tried using a more complex sphere mesh. Now I get "Cooking::cookConvex$$anonymous$$esh: user-provided hull must have less than 256 vertices!" Am I really going to have to chop this mesh up into pieces and apply multiple mesh colliders to the object? This seems way too complicated to make a collision with a simple sphere.
Why are you using sphere meshes with meshcolliders ins$$anonymous$$d of just regular sphere (or if you're in 2D circle) colliders? Those are a lot simpler! That might fix your issue straight away. If you are already using a sphere for your bullet, there's no reason for the meshes you're colliding with to be convex. Using spheres might solve your problem straight out of the box.
You'll probably also end up doing your own calculations for bounces if your game is going to be as simplistic as it is. You'll want consistency rather than the finicky nature of a physics engine's bounces - in my experience, collision normals are somewhat unreliable for arcady bounces. I would take the vector from the bullet to the hit ball, flip it over the direction of the bullet, and use that as the exit vector.
I was using the standard sphere collider. I tried to use a more complex mesh collider thinking that more faces might make more accurate collisions.
By the way, the game is in 3d. They two particular items are locked into a plane though.
sphere collider is based on distance and mesh collider can't ever be so accurate
i would experiment with Edit/Project Settings/Physics (or Physics 2D)
I did take a look into the Physics $$anonymous$$anager, but the only setting that seemed possibly related is the Solver Iteration Count, which I increased, but had no effect.
I zoomed in the camera without effect. I also increased the size of the target ball by 400% and the bounces still came off at the exact same angles (about 45 degree increments).
Answer by PrismicStudios · May 19, 2015 at 06:27 AM
Have you decreased the fixed timestep in settings -> time? This takes up a little more overhead but gives you more accurate results. In my pinball game the physics were very wonky and in order to get accurate ball behavior you should you need more beef in the physics department. I believe the inconsistencies result from where the ball is at the particular frame where the collision happens. Increase this number and you increase accuracy. I don't believe the sphere collider has faces at all actually. I'm almost certain (because it's the cheapest collider to use) it's based simply on distance to center. Hope this helps! I'm going to lunch or I'd tell you the values I used.
Edit: Default is 0.02. for excellent pinball physics I set it to 0.008.
Even in 2021 still the same issue. I can't believe, that collider is NOT ACCURAT$$anonymous$$.. However, your suggestion helped a lot. Thank you
Your answer
Follow this Question
Related Questions
Polygon Collider 2D Not Precise Enough 0 Answers
SphereCast inaccurate? 0 Answers
Trigger Colission not only works sometimes 1 Answer
Object doesn't rotate around it's pivot point on collision 1 Answer
Can't crash airplane into ground 4 Answers