Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

physics.api.velocity #67

Answered by IRobot1
IRobot1 asked this question in Q&A
Discussion options

You must be logged in to vote

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 th…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by IRobot1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants