So I have this Speeder I am making, it works fine except when it gets to an object which is too steep or like a wall it will just tilt its back and slam against it.
I am using a combination of BodyVelocity, BodyAngularVelocity and BodyGyros for this but I am unsure how to prevent this problem.
local a = hit.Parent:findFirstChild("VehicleSeat")
if a ~= nil then
a.MaxSpeed = 0
a.TurnSpeed = 0
end
end
script.Parent.Touched:connect(onTouched)
I didn’t test it, but if it doen’t works, try the second option, duplicate the block, make cancollide false and move it 1 stud before the car hit the wall.
EDIT: I forgot to say that change vehicle seat to the front part of the car, if it touchs it and find the vehicle seat in the car then the scripts do it’s function
no , the op wants so it stops if it collides, only with a part, if its a ramp then nothing should happen…
It’s worth noting that my provided script works , but for some reason he didnt mark it as a solution despite acknowledging that it does
The issue with the .Touched is simply that it isn’t accurate. If for example you bumped into another speeder or the detector part nicked the side of a block, it would stop the speeder completely.
I am not after a solution that is inaccurate, please re-read what I have said.
And by a ramp I mean a surface that is rotated or like slanted e.g. Terrain.
There is also no such thing as a “Ramp” as an object in roblox… please check your answers.
As I have already stated.
This will not work for terrain, yes you can detect if you touch terrain, but you can’t simply know if it was flat or a wall or slightly slanted.
There is little point in me marking every object, that would take a very long time for me to go through and check by myself if an object should be able to stop a speeder or not.
Even if all these conditions did work, .Touched still behaves too weirdly for this to be a good idea.
Touched isn’t good for these things at all. To many edge cases and bugs at high speeds.
For the problem in the GIF of your original post, a strong BodyGyro on the X axis should prevent this from happening. However that would also completely prevent it from going up ramps without a script.
One solution could be to calculate the current translational force your forces are exerting on the model and compare it to the actual acceleration/velocity of any part. If the forces are significantly more than how fast it’s moving, adjust the forces to be less, until all translational forces are zero when the model doesn’t move on the horizontal axis.
Or, to prevent high velocity impacts, you can periodically check how much the velocity changes over time. If the object slows down significantly more in a frame/split second than it can brake, disable the forces for a short time.