1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import * as RE from 'rogue-engine';
- import RapierMovementController from './RapierMovementController.re';
- export default class PlayerPawnInput extends RE.Component {
- movementController:RapierMovementController
- @RE.props.checkbox() useStrafe: boolean = false
- awake() {
- }
- start() {
- this.object3d.traverse(obj => {
- const components = RE.getObjectComponents(obj);
- components.forEach(comp => {
- if (comp instanceof RapierMovementController) {
- this.movementController = comp
- }
- });
- });
- this.object3d.traverse(obj => {
- const components = RE.getObjectComponents(obj);
- components.forEach(comp => {
-
- });
- });
- }
- update() {
- if (RE.Input.keyboard.getKeyPressed("KeyW")) {
- this.movementController.thrust = true
- }
- if (RE.Input.keyboard.getKeyPressed("KeyA")) {
- if(this.useStrafe) {
- this.movementController.strafeLeft = true
- } else {
- this.movementController.rotateLeft = true
- }
- }
- if (RE.Input.keyboard.getKeyPressed("KeyS")) {
- this.movementController.brake = true
- }
- if (RE.Input.keyboard.getKeyPressed("KeyD")) {
- if(this.useStrafe) {
- this.movementController.strafeRight = true
- } else {
- this.movementController.rotateRight = true
- }
- }
- if (RE.Input.keyboard.getKeyPressed("Space")) {
- this.movementController.jump = true
- }
- if (RE.Input.keyboard.getKeyUp("Space")) {
- this.movementController.jump = false
- this.movementController.hasJumped = false
- }
- }
- }
- RE.registerComponent(PlayerPawnInput);
-
|