Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created October 3, 2020 21:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
import { Mesh, PhysicsImpostor, Vector3 } from "@babylonjs/core";
export default class BallComponent extends Mesh {
//...
/**
* Called on the node is being initialized.
* This function is called immediatly after the constructor has been called.
*/
public onInitialize(): void {
this.physicsImpostor = new PhysicsImpostor(this, PhysicsImpostor.SphereImpostor, { mass: 1, friction: 0, restitution: 1 });
this.physicsImpostor.sleep();
}
/**
* Applies the start impulse. This is called on the game is started when the user presses
* the space key on the keyboard.
*/
public applyStartImpulse(): void {
this.physicsImpostor.wakeUp();
this.applyImpulse(new Vector3(45, 0, 45), this.getAbsolutePosition());
}
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment