visionOS - How to change entity velocity with a DragGesture?

Hi,

In a visionOS application I have an entity that is displayed. I can give it a certain velocity by making it collide with another entity.

I would also like to be able to drag the entity and give it a certain velocity via the drag.

I searched in the project examples and found nothing. I also searched on the Internet without finding anything clear on the subject.

Looking at the drag gesture information I found gestureValue.velocity but I have no idea how to use this property. I'm not even sure if this property is useful to me because it's a CGSize so, a priori, not intended for a 3D gesture.

If you have any information that will help me implement what I am trying to do I would be grateful. 🙏🏻

        DragGesture()
            .targetedToAnyEntity()
            .onChanged {
                pValue in
               
                // Some code 
            }
            .onEnded {
                pValue in
                
                //pValue.gestureValue.velocity
            }

Hello @ZeTof:

You're right to point out that velocity, of type CGSize, is a 2D construct.

The 3D properties of DragGesture are worth a look. Both predictedEndLocation3D and predictedEndTranslation3D reflect the velocity of the drag.

Please let us know if you have questions, or need additional information.

Thanks, Steve

visionOS - How to change entity velocity with a DragGesture?
 
 
Q