|Topic was automatically imported from the old Question2Answer platform.
I’m trying to put together a VR Demo, and I’m having some issues figuring out throwing objects.
From the XRPose class I can get the angular and linear velocities of a given pose, so if I drop an object that I’ve previously attached to the Aim pose, I should be able to get the linear and angular velocities of that pose and apply them to the object on the same frame that I reparent the object to the scene root and it’ll move and spin in the way the user would expect when they open their hand.
So the issue that I’m running into is that both these velocity values appear to be in the XROrigin’s frame of reference. Linear velocity works okay if I rotate it on the global Y axis by however much the XROrigin is rotated (multiplying it by the XROrigin’s transform, or using
to_global() do NOT work, annoyingly)
But I can’t figure out what to do with the angular velocity to make it work right. Applying it as is doesn’t work. Converting it
to_global() doesn’t work. Multiplying
to_global() by the inverse transform of the thrown object doesn’t work. Rotating it like I do the linear velocity and doing any or all of the other steps doesn’t work.
Angular velocity is a vector value just like linear velocity, so I don’t see why you couldn’t use the same techniques to transform it into world space. Are you sure you’re using to_global correctly? Are you sure you need to transform these values at all, or are they already in world space?
TRAILtheGREAT | 2023-04-27 23:58
They’re definitely not originating in world space.
I reparent the gun to scene root on release, then apply the velocities.
So in the linear examples I’m pushing on XROrigin’s X axis when I release the gun. When the XROrigin is aligned with the world, everything seems normal, but after I snap turn, the gun gets pushed on World X when I release when linear velocity is uncorrected. When I use
to_global() it seems to work right when origin is aligned and turned to the left, but when I turn to face the right, it’s wrong again.
For the angular examples I turned off gravity to make it easier to see what’s happening. Uncorrected angular velocity looks okayish when the axis of spin on release is approximately the same as global Y, but when I point the gun up and spin it, it’s clearly wrong. When I try multiplying by the gun’s inverse transform it almost seems right again, until I try to spin along the gun’s Z-axis, and then it’s bonkers.
(and there’s no physics collision on the hand, so the issue isn’t that it’s bouncing off the hand or something)
DKesserich | 2023-04-28 01:03
Are you sure that the velocity is in the frame of the XR Origin’s transform and not the "hand"s transform? (sorry, I’m not super familiar with Godot’s XR Tools) Whenever you throw the gun, it looks like your hand is always facing forward, which would explain why the linear velocity behavior is mostly normal. This could also explain the strange behavior with the angular velocity, since you have to rotate your hand in order to test it.
TRAILtheGREAT | 2023-04-28 17:07