Skip to content

Instantly share code, notes, and snippets.

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
You can’t perform that action at this time.