-
How do I get the current velocity? There only appears to be methods to set, copy and subscribe. Also, what's the difference between set and copy? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I'm trying to use the velocity of one physics object (motion controller), to set the velocity of another physics object (which I just released). Essentially, throw the object I was holding by using the velocity of my hand to set the velocity of the ball as its released. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
It can be done, but is not obvious. Subscribe to velocity of physics object that's moving private velocity_subscription?: () => void;
velocity = [0, 0, 0] as NgtTriplet;
handphysics!: NgtPhysicBox; // initialize first
boxphysics!: NgtPhysicBox; // initial too
this.velocity_subscription = this.handphysics.api.velocity.subscribe(next => {
this.velocity = next;
});
//... when finished, unsubscribe
this.velocity_subscription?.(); When object is released, set the velocity to match the velocity being monitored this.boxphysics.api.velocity.set(this.velocity[0], this.velocity[1], this.velocity[2]) You might need to use a PointToPoint constraint to connect the objects. See the code for mousepick example |
Beta Was this translation helpful? Give feedback.
It can be done, but is not obvious. Subscribe to velocity of physics object that's moving
When object is released, set the velocity to match the velocity being monitored
You might need to use a PointToPoint constraint to connect the objects. See th…