I am trying to make one of those bobing clown punching things and would like to avoid using physics for it. but i am having trouble taking a object hitting it and creating a rotation from that hit to make it look like it is moving correctly.
is anyone better at vector math that could throw out a suggestion or does anyone know if a command in unity to convert a vector impact to a rotation direction?
I know you do not wish to use physics but it would be simpler if you did. Create an empty game object to represent the “base” of the clown. Then I would add a hinge joint connected to the rigid body of the clown. That way he always spins on the bottom point of the hinge joint, but doesn’t move. Use AddForce at Position
Using physics carrys to much extra with it. gravity, friction, torque etc. by using just a rotation from a collision vector it reduces the cost (if the script is build cheap) and is 100% controlable. the other issue is that i have some parent objects that have collision on them and i am starting to have to many collisions to account for.
for example the parent and child shouldnt collide… easy to fix. but now i want the parent to collide with the environment but not the child… a little harder. now i want projectiles to collide with the child but not the parent… and the list goes on.
In other engines this can be done with physics channels in PhysX but i cant find a way to do that in Unity so instead i can fix all of the issues by not using physics and by doing based on specific impacts and rotating the object.
I have part of the equation… i am using a Quaternion.AngleAxis for it but now need to convert it to world and find a way to make it an offset to my objects rotation and to not replace my objects current orientation.
does anyone have a good method for taking a Quaternion and just “adding” it to my current orientation?
everytime i try to add two quaternions it always says that i cant use a “+” with a left side Quaternion and a right side quaternion. The only way i have found to combine two quaternions in any way is with *… which doesnt combine them but it is a math operator.
if (collision.relativeVelocity.magnitude > 2)
{
var contact = collision.contacts[0];
This is where i am at so far… closer but still not there.
I would rather do it as an offset because a multiply is wrong. I cant find a solution to add etc. though.
I also need to understand why its not always rotating the same way. i think its because when i change where the object gets hit from i recieve either pos or neg numbers and need to make sure its consistent. hence one of the issues with *.