feat:(game) set a real starting pose

skidmarks
Alex 2024-01-23 15:02:38 +01:00
parent 16b2bbb93a
commit 7daaf262aa
3 changed files with 14 additions and 4 deletions

BIN
public/sounds/engine.wav Normal file

Binary file not shown.

View File

@ -25,7 +25,7 @@ export const FlameParticle = ({ position, png, turboColor, delay = 0 }) => {
return geom; return geom;
}, [position]); }, [position]);
useFrame(() => { useFrame(({clock}) => {
if (!initialized) return; if (!initialized) return;
pointsRef.current.position.y += 0.03; pointsRef.current.position.y += 0.03;

View File

@ -6,6 +6,8 @@ import {
ContactShadows, ContactShadows,
Sphere, Sphere,
OrbitControls, OrbitControls,
Trail,
PositionalAudio,
} from "@react-three/drei"; } from "@react-three/drei";
import { useFrame, useThree } from "@react-three/fiber"; import { useFrame, useThree } from "@react-three/fiber";
import { useRef, useState, useEffect, useCallback } from "react"; import { useRef, useState, useEffect, useCallback } from "react";
@ -63,6 +65,7 @@ export const PlayerController = () => {
let targetXPosition = 0; let targetXPosition = 0;
let targetZPosition = 8; let targetZPosition = 8;
const [steeringAngleWheels, setSteeringAngleWheels] = useState(0); const [steeringAngleWheels, setSteeringAngleWheels] = useState(0);
const engineSound = useRef();
const [scale, setScale] = useState(0); const [scale, setScale] = useState(0);
@ -296,6 +299,11 @@ export const PlayerController = () => {
// Update the kart's rotation based on the steering angle // Update the kart's rotation based on the steering angle
setSteeringAngleWheels(steeringAngle * 25); setSteeringAngleWheels(steeringAngle * 25);
// SOUND WORK
console.log(body.current.translation())
}); });
return ( return (
@ -303,7 +311,7 @@ export const PlayerController = () => {
<RigidBody <RigidBody
ref={body} ref={body}
colliders={false} colliders={false}
position={[0, 20, 0]} position={[8, 20, -96]}
centerOfMass={[0, -1, 0]} centerOfMass={[0, -1, 0]}
mass={3} mass={3}
> >
@ -320,7 +328,7 @@ export const PlayerController = () => {
}} }}
</RigidBody> </RigidBody>
<group ref={kart}> <group ref={kart} rotation={[0, Math.PI / 2, 0]}>
<group ref={mario}> <group ref={mario}>
<Mario <Mario
currentSpeed={currentSpeed} currentSpeed={currentSpeed}
@ -376,6 +384,8 @@ export const PlayerController = () => {
fov={50} fov={50}
ref={cam} ref={cam}
/> />
{/* <PositionalAudio ref={engineSound} url="./sounds/engine.wav" autoplay loop distance={10}/> */}
</group> </group>
</group> </group>
); );