This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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