- Home /
Calculating Sphere vs. Plane Friction
Hi everyone.
I'm making a 2D side on game where you play as a ball, sort of like morph ball from Metroid.
I've come across a really annoying aspect of PhysX friction that I want to avoid.
I have it so that your movement is controlled by both a force in the direction you are trying to move and torque that moves you in that direction as well so that you have greater control over your movements on the ground but still some control in the air.
So when you are moving left, the ball is spinning counter clockwise so that the bottom of the ball is moving right (pushing you left when you are touching the ground) and the top of the ball is moving left (pushing you right when you are touching the roof).
The annoying part is the movement of the top of the ball.
If you are trying to get into a hole in a wall to your left (by moving left and jumping) and you hit the roof during the jump, the friction between you and the roof causes your spin to propel you to the right (away from he wall) instead of the direction you are moving.
After considering all the possibilities I could think of, I think the best solution is for me to use a physic material with no friction and calculate the friction myself in a script where I can simply ignore collisions that are above me.
After looking around for ages, I still haven't been able to find anywhere the can explain how to calculate the forces involved in friction in a way that I can understand. I have no idea to calculate things like the acceleration and angular acceleration gained by the ball or the appropriate forces that the ball applies to whatever it is colliding with if that thing has a rigidbody.
Can anyone explain how to do these calculations, point me to somewhere that does or think of any other ways that I could get around this problem?
Thanks in advance.
Answer by Bunny83 · Jan 24, 2012 at 05:50 AM
I wouldn't "roll" the ball at all ;) Just use a sphere collider (or maybe a character controller) and just move it manually. You can rotate the visible sphere, which should be child in this case, according to the movement speed.
At least in Super Metroid (SNES - which i completed again recently :D ) you just move. there is no ball physic at all. Can't say anything about the newer games. It's up to you how you want the movement to be.
I don't think your friction solution can be implemented that easy. In phyics calculation friction-based forces are one of the most complicated things, since they results in a linear force and a torque.
But if I don't roll the ball, your movement on the ground is exactly the same as in the air. I tried just increasing the force you give yourself while on the ground but it just didn't feel right to have nice proper physics objects flying around everywhere while the player uses some whacky fake physics.
The newer $$anonymous$$etroid games are quite physics based, except that they don't suffer from my problem.
I would suspect that friction calculations being complicated is the only reason I haven't found anything that makes sense while I was looking around. But I don't see what the problem is with the results being linear force and torque, since I can apply them rather easily in unity.
Your answer
Follow this Question
Related Questions
Friction issue with rotating sphere 1 Answer
Strange sphere/physics rolling behaviour when scaled 1 Answer
How to apply frictional Torque 2 Answers
Sailing Ship - How to apply torque without lateral friction killing all velocity? 1 Answer
Returning a rigidbody back to its original x and z rotations through physics forces. 2 Answers