Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created August 1, 2020 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/0127f813635acdc0459c9160adb7993d to your computer and use it in GitHub Desktop.
Save flushpot1125/0127f813635acdc0459c9160adb7993d to your computer and use it in GitHub Desktop.
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