Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
export default class p_player extends Mesh {
//途中省略
//32 : space
@onKeyboardEvent([32], KeyboardEventTypes.KEYDOWN)
private _shot():void{
this._launchBall();
}
private _launchBall(): void {
const ball = Mesh.CreateSphere("ball", 10, 1);
ball.position.copyFrom(this.getAbsolutePosition());//Playerの位置を指定 (this = p_player)
ball.physicsImpostor = new PhysicsImpostor(ball, PhysicsImpostor.SphereImpostor, { mass: 1, friction: 0, restitution: 1.0 });
const force = this.getDirection(new Vector3(5, 0, 8));
ball.applyImpulse(force, ball.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.