-
I’m trying to make a system where the character’s character follows a part using AlignPosition and AlignOrientation. I’m currently trying to make it so that the CharacterController(the part that the character is connected to make it move around) will stay slightly above the ground using Raycasts.
-
The Issue is that the part just starts glitching all over the place and I can’t find any tutorials that work with my code to make the suspension system.
-
I tried looking on YouTube and the DevForum but all I found was stuff about car suspension which I don’t know how to implement into just a single part
Here is my current code and what happens(I haven’t pressed any keys to trigger the W A S D functions I made):
local function raycastDown()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {character}
raycastParams.IgnoreWater = true
local raycastResult = workspace:Raycast(characterController.Position + Vector3.new(0, -1, 0), Vector3.new(0, -5, 0), raycastParams)
if raycastResult then
characterController.Position = Vector3.new(characterController.Position.X, raycastResult.Position.Y + 3, characterController.Position.Z)
--local rotation = CFrame.new(raycastResult.Position, raycastResult.Position + raycastResult.Normal)
--local yaw, pitch, roll = rotation:ToEulerAnglesYXZ()
--characterController.Orientation = Vector3.new(math.deg(pitch), math.deg(yaw), math.deg(roll))
else
end
end
robloxapp-20241013-1509251.wmv (2.0 MB)