Hi, so I’ve made a kart game and I need to add some way to slow down the player when he’s out of the track. I’ve made a mesh based on my track’s bounds and it’s supposed to set a variable “on” when I’m inside the mesh (so when I’m overlapping it). The problem is whenever I go in the mesh, the actor think I’m going out of it (it automatically trigger the end overlap event, which set the variable “off”)
I’ve put a print string to check what happen and when I start overlapping, it set the variable “on” for 1 frame then it directly consider that I’m out of it so it set the variable back to “off”.
Is there some others solutions to slow down the kart when I’m out of track ? Because that’s the only solution that I had in mind.
I think here it would be better to use another method, also overlap events + fast movements is not a good combo, you could use instead a line trace pointing down and detect if it’s hitting either the road or the dirt and change the variable with that.
Another point is having the need for a mesh with precise collision and the exact same shape of your track is not the best workflow, it’ll bring issues sooner or later.
I would recommend setting a PhysMaterial for each track material – gravel, pavement, hay, etc.
The PhysMaterial can then map to properties for traction, friction, tire sounds, dust/kickup particles, etc.
Finally, you should raycast from the center of each wheel, down to the ground (ignoring the car actor) to find what ground each wheel is over. You can then affect traction, sounds, and other effects based on that result.