You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? im trying to make a raycast suspension car
-
What is the issue? for some reason the car keeps moving forward instead of standing still
-
What solutions have you tried so far? I did several tests with the physics of the car and with the code but no matter what I do it always leans forward.
here is a video of the car:
here is the video that im using: Making Custom Car Physics in Unity (for Very Very Valet) - YouTube
and here is the code that im using:
-- Chassis is the main part of the car
-- Settings is a folder with the car settings
if raycastResult then
local Force = 0
local Offset = 0
local Velocity = 0
-- calculates the raycast offset
local dist = (origin - raycastResult.Position).Magnitude
Offset = Settings.Height.Value - dist
-- calculates the spring velocity
local springDiretion = Chassis.CFrame.UpVector
local worldVelocity = Chassis:GetVelocityAtPosition(origin)
Velocity = springDiretion:Dot(worldVelocity)
Force = (Offset * Settings.Strenght.Value) - (Velocity * Settings.Damping.Value)
Chassis:ApplyImpulseAtPosition(springDiretion * Force, raycastResult.Position)
end
I found that the car always goes forward, regardless of whether attachment in the front