fix:(game) just fixed a small issue causing gained boost to stop if the player is drifting

skidmarks
Alex 2024-01-25 04:19:06 +01:00
parent be364fca25
commit 73343a8739
3 changed files with 16 additions and 8 deletions

View File

@ -7,7 +7,7 @@ import { shaderMaterial } from '@react-three/drei'
import { extend, useFrame } from '@react-three/fiber'
import { Color, DoubleSide, AdditiveBlending } from 'three'
export default function FakeFlame({ falloff = 10, glowInternalRadius = 1.0, glowColor = 'orange', glowSharpness = 1.0 , isBoosting,}) {
export default function FakeFlame({ falloff = 3, glowInternalRadius = 1.0, glowColor = 'orange', glowSharpness = 1.0 , isBoosting,}) {
const FakeFlame = useMemo(() => {
return shaderMaterial(
{
@ -39,10 +39,10 @@ export default function FakeFlame({ falloff = 10, glowInternalRadius = 1.0, glow
float glitchStrength = sin(glitchTime) + sin(glitchTime * .05) + sin(glitchTime * .36);
glitchStrength /= 2.0;
glitchStrength = smoothstep(0.2, 0.8, glitchStrength);
glitchStrength *= 0.;
glitchStrength *= 0.05;
modelPosition.x += (random2D(modelNormal.xx + time) - 0.5) * glitchStrength;
modelPosition.x += (random2D(modelNormal.xx - time) - 0.2) * glitchStrength;
modelPosition.y += sin(smoothstep(0.3, vUv.y - 1.8, position.y) * 2.) * sin(time * 24.);
modelPosition.y += sin(smoothstep(0.3, vUv.y - 2.2, position.y) * 2.) * sin(time * 48.);
modelPosition.z += sin(smoothstep(0., vUv.x - 0.8, position.z) * 2.) * sin(time * 24.) * .6;
gl_Position = projectionMatrix * viewMatrix * modelPosition;
@ -107,7 +107,7 @@ export default function FakeFlame({ falloff = 10, glowInternalRadius = 1.0, glow
q.x *= 2.;
q.y *= 2.;
float strength = floor(q.x+1.5);
float T3 = max(2.,2.25*strength)*time;
float T3 = max(2.,2.25*strength)*time * 3.;
q.x = mod(q.x,1.)-0.5;
q.y -= 0.05;
float n = fbm(strength*q + vec2(0,T3));

View File

@ -209,15 +209,22 @@ export const PlayerController = () => {
// RELEASING DRIFT
if (boostDuration.current > 1 && !jumpIsHeld.current) {
setCurrentSpeed(boostSpeed)
boostDuration.current -= 1 * delta * 144
targetZPosition = 10
setIsBoosting(true)
} else if (boostDuration.current <= 1) {
targetZPosition = 8
setIsBoosting(false)
}
if(isBoosting && boostDuration.current > 1){
setCurrentSpeed(boostSpeed)
boostDuration.current -= 1 * delta * 144
targetZPosition = 10
} else if (boostDuration.current <= 1) {
setIsBoosting(false)
targetZPosition = 8
}
// CAMERA WORK
cam.current.updateMatrixWorld()

View File

@ -16,7 +16,8 @@ export function Mario({ currentSpeed, steeringAngleWheels, isBoosting, ...props
const frontRightWheel = useRef()
const rearWheels = useRef()
const frontWheels = useRef()
const [scale, setScale] = React.useState(0)
const [scale, setScale] = React.useState(1)
// isBoosting = true;
useFrame((_,delta) => {
const rotation = currentSpeed / 100