Hey all, welcome to a brand new week!
Here’s a challenge for the physics-savvy of you around: I’d like to have a ball bounce on walls, without ever stopping, while keeping a constant speed (think about the “bouncing ball of mass destruction” in Men in Black).
Sounds awful simple… hell, this kind of bouncing ball/box is the often the first tutorial in a 2D engine, and we’ve all seen it a hundred times on screen-savers etc.
But I want it 3D, and I want it with physics, for various reasons, like: what if my spherical ball now becomes a rugby ball? What if the objects the ball collides with are moving and I want them to apply a lifting effect? (not sure of the term, I’m a very poor tennis player.)
[Really, the above says it all about what I need, but I’ll elaborate on what I’ve tried for those interested.]
Anyway I’ve been struggling with the physics engine for weeks now and I just can’t get it right.
I started with a sphere+RigidBody+ConstantForce, with a relative forward force, but since the ball’s constantly spinning the rebounds are just very random, sometimes the ball’s trajectory is straight, sometimes it’s curvy and it will hit the same wall repeatedly… not really bouncy.
So I tried to freeze its rotation, but that’s bad, it kinda breaks the whole physics thing and the engine acts weird.
Another reason this wasn’t satisfactory is that I had little control on the ball’s speed (remember, I want it constant), and it was decelerating/accelerating on each rebound.
So I took out the ConstantForce to control the ball myself, setting its velocity and using Vector3.Reflect on collisions to make it bounce.
It kinda did the trick, but since then I’ve learnt that “setting velocity on a non-kinematic rigidbody is baaad”.
Plus I wasn’t really using the physics engine for anything else that collision-detection => try using Vector3.Reflect on a rugby ball, it’s disappointing.
I also tried to play around with physics materials, but let’s be honest, I just don’t understand what I’m doing and trying different combinations is just endless and leads me nowhere.
The funny thing is, a lot of “ball physics” threads have appeared on the forum these days, but I’ve read them all and while it helped understanding more about the physics engine, it didn’t solve my problem.
At least I came to realize that I had wrong expectations about the physics engine, and that my unstoppable bouncing ball kinda breaks the whole “realistic physics” idea.
For example, it’s not physically possible to have a 100% constant speed, the ball’s gotta have an acceleration of some sort. But if I control it wisely, I can make it so that this acceleration is super-fast and the speed maxes out (right?), so that the user won’t see the difference.
Well, here I am. I usually prefer asking precise technical questions instead of this “please make my game for me” question, but I’m just lost and need an expert opinion! Without proper, easy-to-use rebounds, my game just goes down the drain.