I’m creating a Pong-like game in Unity 4.6.1, and I’d like the ball to look more “alive” than a static sprite. I’d like for it to look like it’s rolling, in the direction of the velocity of its Rigidbody2D, and maybe even with some spin on it.
I’m not necessarily looking for a complete solution. Just suggestions as to how I can achieve this effect. I’ve thought up two suggestions myself, but think these might be stupid or painful to achieve:
Create the sprite with a Collider2D, disable the sprite renderer, and add a child sphere to it with the same width as the sprite’s Collider2D (with some texture to see how it is rotating). Then I’d manually add torque to the sphere, depending on the velocity of the 2D rigidbody. I’m afraid, that decoupling the sphere from the physics, might make it look unrealistic. I’ve tried the following, but it does not even remotely give the desired effect (it seems to just spin randomly):
// Changing the 3D rigidbody of the sphere, using the velocities of
// the rigidbody2D of the sprite
Sphere.rigidbody.AddTorque(rigidbody2D.velocity.x, rigidbody2D.velocity.y, 0, ForceMode.VelocityChange);
Using this instead, I can get it to look like it is rolling correctly, but only when the ball is rolling horizontally. When the ball starts rolling laterally, it looks weird, until it returns to a horizontal movement again. It also rotates way too slow compared to what it should, and multiplying the value doesn’t do anything.
Sphere.rigidbody.AddTorque(0, -rigidbody2D.velocity.x, 0, ForceMode.VelocityChange);
- Somehow use a shader on the sprite to achieve the effect (no idea how, as I’m supern00b at shaders).
Any other suggestions? Thanks in advance for your comments.