I’m trying to make a custom character, and running into certain issues that I’d like to fix in the easiest possible way.
So at the moment, I am just using a Humanoid. Mostly because all the movement controls/etc. are already implemented, without needing to be coded. Problem is because my characters movement is now just them sliding on the RootPart (slightly transparent red part), so especially when they on edges, the character slides down them, instead of being still.
Note, I am using a BodyGyro to rotate the character based on the angle of the slope they are standing on. It’s not perfect, as you can still see gaps between the RootPart and the slope. I’d ultimately like to get this past to be perfectly flush with the slope. Obviously on slope edges will be harder, but yeah. For the general slope it should match.
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local XZGyro = Instance.new("BodyGyro")
XZGyro.MaxTorque = Vector3.new(3e5, 0, 3e5)
XZGyro.P = 5e5
XZGyro.Parent = HumanoidRootPart
-- Raycast parameters
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Blacklist
Params.FilterDescendantsInstances = {Character}
Params.IgnoreWater = true
local function Render()
-- Make ray
local Result = workspace:Raycast(
HumanoidRootPart.Position,
Vector3.new(0, -10, 0),
Params
)
if not Result then return end
local CurrentRightVector = HumanoidRootPart.CFrame.RightVector
local UpVector = Result.Normal
local NewFacialVector = CurrentRightVector:Cross(UpVector)
local Tween = TweenService:Create(
XZGyro,
TweenInfo.new(0.2),
{
CFrame = CFrame.fromMatrix(
HumanoidRootPart.Position,
CurrentRightVector,
UpVector,
NewFacialVector
)
}
)
Tween:Play()
end
RunService.RenderStepped:Connect(Render)
I’ve tried looking into multiple gravity control places/etc. to see how they get sticking to walls, etc. to work, but they usually have tons of scripts and complex code.
But my main question with all this, is if it’d be better to use BodyMovers, and how can I effectively go about implementing that?