- Home /
Reflect a rigid body without rotating it
Imagine a spinning top that moves at a constant speed. It uses rigidbody and addForce to knock other objects over. I want it to reflect its velocity and bounce off when it hits something, and maintain its constant speed. But from other people's answers, it involves rotating the projectile itself, which I don't want. How do I make a rigidbody reflect off without rotating it?
Answer by Captain_Pineapple · Jun 10, 2018 at 10:10 AM
Hey there,
you might just take the rigidbodys velocity and "reflect" it according to the object you hit.
Simply access the velocity vector and use This Function to "invert" the vector. Finding the normal to do so will be your problem though (I think the Collision information provided by OnCollisionEnter might provide it). If you need more specifics on this topic you should post more information about your setup/code/objects, to clarify what you want to achive.
The top should bounce off of whatever it hits, including squares and spheres. Other codes I tried to use makes the top reflect off of things just fine, but it also requires the top itself to be rotated. I have a camera attached to the non-spinning portion of the top, and rotating the top will also rotate the camera, which can be very disorienting. If the top hits a sphere or a capsule, it rotates the top sideways.
why not unparent the camera, quaternion.inverse the top, then relink the camera again?
Well when you just fiddle with the velocity your "top" will not be turned. It simply will move in another direction.
I don't know how to reverse velocity though.
Your answer
Follow this Question
Related Questions
How to find rigidbody velocity magnitude at the moment it is reflecting off of the other one? 1 Answer
Weird results when using Vector3.Reflect and RaycastHit.normal? 1 Answer
How to calculate a RigidBody2D's bounce from a collider? 1 Answer
Reflect a Rigidbody in Javascript 0 Answers
Refer to a parent Rigidbody 1 Answer