Hi, I’m developing a table soccer game and I’m currently developing the player’s physics.
Basically it’s a bar with a block attached to it with a Joint. I then tried to make the players and a little ball interact and I noticed that sometimes, when the box is spinning really fast, the ball would pass right through the box, so I googled for a solution and found that making the scale bigger works, so I scaled up everything (10x bigger), but then the gravity looked strange so I turned that up 10x as well and it works as expected but I fear that this is going to be a mess in the future (a table soccer that is 10m long and 10tall isn’t normal).
See the screenshot.
My question is “how can I make the physics work correctly even if my game is in a small world (players should be about 0.15 units tall)”.
Thanks
ps: I know this isn’t strictly a scripting question but I couldn’t figure out where else to post it.
I don’t think it’ll be messy — you’ve just redefined your units. Instead of 1 Unity unit being 1 meter, you’ve made it 1 decimeter. Everything should work just fine as long as you always remember that; so any speed should be defined in dm/sec, acceleration is in dm/sec^2, positions are all in dm, etc.
Thanks for the reply. I don’t know, isn’t there any other way of solving it without having to mess with the scale? I’m still a little bit afraid, for example, if I use realtime shadows (Unity Pro) I will have to set Shadow distance to a huge value, if everything is bigger, in order to see decent shadows, won’t this a big performance problem?
Correct me if I’m wrong here, but the only issue you are seeing is that with fast moving objects, collisions get ignored?
If that is indeed the case, try using raycasting (or spherecast) instead of trying to rely on the actual colliders to tell you when a collision happens. There are plenty of tutorials and docs on how to use ray/sphere cast for fast moving object collision (mostly around bullet collision), so you should be able to google a bit for that and find what you need.
It’s that problem and others as well. For example:
I have different set of floor tiles that get infinitely generated when the ball comes close to the edge of one and is about to fall into nothing (so basically the ball can go anywhere and it will always have floor underneath it). If I set the scale like the real world, it happens from time to time that the transition between the two floor tiles isn’t smooth, the ball behaves like there is a little gap or level difference. I know there isn’t 'cause the tiles are placed perfectly through code.
In the case of the floor, I would play with the idea of making tile placement animation based, then just check the ball’s position against where the floor should be. That is assuming, of course, that the floor has no slope and is always at the same ‘y’ level.
Another thing to try is making the fixed update time step smaller. I can’t imagine doing a table tennis game at the default 50Hz. In VRC Pro I ended up running things at 250Hz, and those cars we were doing are still a lot bigger and heavier than a ping pong ball.