Skip to content

Commit

Permalink
thrust on input
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisfarms authored and ldunnplaymint committed Oct 24, 2024
1 parent 9be8619 commit 3cb53d6
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/examples/spaceshooter/renderer/ShipEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
Mesh,
Object3DEventMap,
PositionalAudio as PositionalAudioImpl,
Vector2,
Vector3,
} from 'three';
import { getPlayerColor } from '../../../gui/fixtures/player-colors';
Expand Down Expand Up @@ -56,7 +55,6 @@ export default memo(function ShipEntity({
Array.from(worldRef.current.players.entries()).find(
([_id, p]) => p.ship === eid,
) || [undefined, undefined];
const vmagPrev = useRef<number>(null!);
const groupRef = useRef<Group>(null!);
const shipRef = useRef<Group<Object3DEventMap>>(null!);
const thrustRef = useParticleEffect(groupRef, fxThrusterData, [-3.5, 0, 0]);
Expand Down Expand Up @@ -236,17 +234,9 @@ export default memo(function ShipEntity({

// update thruster effect (if accelerating)
if (thrustRef.current) {
const vmag = new Vector2(
world.components.velocity.data.x[eid],
world.components.velocity.data.y[eid],
).length();
const accelerating =
world.components.entity.data.active[eid] &&
vmagPrev.current !== null &&
vmag !== vmagPrev.current;
vmagPrev.current = vmag;
const accelerating = hasInput(player.input, Input.Forward);
if (accelerating) {
thrustRef.current.n = 15;
thrustRef.current.n = 3;
} else if (thrustRef.current.n > 0) {
thrustRef.current.n -= 1;
}
Expand Down

0 comments on commit 3cb53d6

Please sign in to comment.