fix:(game) just fixed a small issue causing gained boost to stop if the player is drifting
parent
be364fca25
commit
73343a8739
|
@ -7,7 +7,7 @@ import { shaderMaterial } from '@react-three/drei'
|
||||||
import { extend, useFrame } from '@react-three/fiber'
|
import { extend, useFrame } from '@react-three/fiber'
|
||||||
import { Color, DoubleSide, AdditiveBlending } from 'three'
|
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(() => {
|
const FakeFlame = useMemo(() => {
|
||||||
return shaderMaterial(
|
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);
|
float glitchStrength = sin(glitchTime) + sin(glitchTime * .05) + sin(glitchTime * .36);
|
||||||
glitchStrength /= 2.0;
|
glitchStrength /= 2.0;
|
||||||
glitchStrength = smoothstep(0.2, 0.8, glitchStrength);
|
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.5) * glitchStrength;
|
||||||
modelPosition.x += (random2D(modelNormal.xx - time) - 0.2) * 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;
|
modelPosition.z += sin(smoothstep(0., vUv.x - 0.8, position.z) * 2.) * sin(time * 24.) * .6;
|
||||||
|
|
||||||
gl_Position = projectionMatrix * viewMatrix * modelPosition;
|
gl_Position = projectionMatrix * viewMatrix * modelPosition;
|
||||||
|
@ -107,7 +107,7 @@ export default function FakeFlame({ falloff = 10, glowInternalRadius = 1.0, glow
|
||||||
q.x *= 2.;
|
q.x *= 2.;
|
||||||
q.y *= 2.;
|
q.y *= 2.;
|
||||||
float strength = floor(q.x+1.5);
|
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.x = mod(q.x,1.)-0.5;
|
||||||
q.y -= 0.05;
|
q.y -= 0.05;
|
||||||
float n = fbm(strength*q + vec2(0,T3));
|
float n = fbm(strength*q + vec2(0,T3));
|
||||||
|
|
|
@ -209,15 +209,22 @@ export const PlayerController = () => {
|
||||||
// RELEASING DRIFT
|
// RELEASING DRIFT
|
||||||
|
|
||||||
if (boostDuration.current > 1 && !jumpIsHeld.current) {
|
if (boostDuration.current > 1 && !jumpIsHeld.current) {
|
||||||
setCurrentSpeed(boostSpeed)
|
|
||||||
boostDuration.current -= 1 * delta * 144
|
|
||||||
targetZPosition = 10
|
|
||||||
setIsBoosting(true)
|
setIsBoosting(true)
|
||||||
} else if (boostDuration.current <= 1) {
|
} else if (boostDuration.current <= 1) {
|
||||||
targetZPosition = 8
|
targetZPosition = 8
|
||||||
setIsBoosting(false)
|
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
|
// CAMERA WORK
|
||||||
|
|
||||||
cam.current.updateMatrixWorld()
|
cam.current.updateMatrixWorld()
|
||||||
|
|
|
@ -16,7 +16,8 @@ export function Mario({ currentSpeed, steeringAngleWheels, isBoosting, ...props
|
||||||
const frontRightWheel = useRef()
|
const frontRightWheel = useRef()
|
||||||
const rearWheels = useRef()
|
const rearWheels = useRef()
|
||||||
const frontWheels = useRef()
|
const frontWheels = useRef()
|
||||||
const [scale, setScale] = React.useState(0)
|
const [scale, setScale] = React.useState(1)
|
||||||
|
// isBoosting = true;
|
||||||
|
|
||||||
useFrame((_,delta) => {
|
useFrame((_,delta) => {
|
||||||
const rotation = currentSpeed / 100
|
const rotation = currentSpeed / 100
|
||||||
|
|
Loading…
Reference in New Issue