How do I correctly apply "rigid.AngularVelocity" to a node on the water (C#) ?


photo

Recommended Posts

I have a player controlled node tied to a camera. That node is set to rigid body in the code. I want the rigid body to be impacted by the water mesh surface with angular physics like the standard rigid body in water mesh. However my programmed rigid body seems to be stuck using only the camera to update its rotation. I want the water mesh surface to impact the rotation as well.

Here is the portion of my code in which I am attempting to have the water impact the rigid body for angular movement. Can anyone help point out where I am going wrong, or how to do it correctly? Thank you

    quat q;
    q.x = rigid.AngularVelocity.x * Game.IFps;
    q.y = rigid.AngularVelocity.y * Game.IFps;
    q.z = rigid.AngularVelocity.z * Game.IFps;
    q.w = 0.0f;
 
    quat orientation;
    orientation = playerDummy.GetWorldRotation();
    q = q * orientation;
 
    orientation.x += q.x * 0.5f;
 
    orientation.y += q.y * 0.5f;
 
    orientation.z += q.z * 0.5f;
 
    orientation.w += q.w * 0.5f;
 
    orientation.Normalize();
 
        node.SetWorldRotation(node.GetWorldRotation() * new quat(orientation));
 
    }
Link to post

;) 

ok  I will go back and look at using the prior code you provided to me (assuming that is what you are implying). Thank you. 

Link to post
On 8/30/2020 at 3:31 PM, AttackGorilla said:

;) 

ok  I will go back and look at using the prior code you provided to me (assuming that is what you are implying). Thank you. 

LOL No I actually was serious, I did not find the code in the sample. So let me know what works best. Thanks

Link to post

I was able to program some relatively decent angular velocity movement with angular impulse and world orientation. However I did not anticipate the physics to flip my object over, which I should have known it would do. I wanted to make a boat that would still return upright and maintain some uprightness while effected by angular physics of waves. Coding in the rigidity of the object to keep it upright is beyond my programming capability. So I will most likely code in slight orientation, rocking movement changes to the object based on what direction the player moves the object Rather than water angular impulses. This won’t be true physics but it should be semi believable (hopefully). 

Link to post

Thanks for the help. I will definitely showcase once I am further along. I have very little free time so development is slow. 

Link to post