lightmap Posted November 22, 2017 Posted November 22, 2017 Hello I'm new at physics In order to have proper physical collisions, instead of setting position and rotation I need to apply velocities to rigid body in scene - player grabs immovable object and rotate self from hand position with vr controller I successfully control player translation with setLinearVelocity, but for setAngularVelocity, origin of rotation placed in center of mass and it wrong with respect to rotating body at hand contact point setAngularVelocity have only one incoming parameter, and I can't change center of mass, how I can set offsetted angular rotations? thanks
Greg.Mildenhall Posted November 23, 2017 Posted November 23, 2017 Sounds like you need to add a joint. Otherwise you'd have to apply the angular velocity at the CoM and then also apply a linear velocity to compensate for the offset - and since you'd have to calculate the offset velocity anew each frame, error/lag will slowly pull the two bodies apart anyway.
lightmap Posted November 23, 2017 Author Posted November 23, 2017 thanks Greg for joint tip https://developer.unigine.com/en/docs/2.6/principles/physics/joints/ like - create Fixed Joint only for a grab moment, between controller and player body? it has only available methods is setRotation0,1 - no methods for setting angular velocity, so instead of angular velocity vector, I need to calculate rotation matrix...or it automatically transferred to second body when one of jointed bodies rotated? or with compensation for the offsetted angular velocity - do linear velocity equals to vector between old and new body position?
Greg.Mildenhall Posted November 23, 2017 Posted November 23, 2017 Adding the joint says "this part of the player must stay at this point in space". The physics engine will apply that constraint in its calculations of linear and angular velocities for the next frame - so it should automatically set the velocities you need. You just need to configure the joint.
Recommended Posts