Hello! I want to make a movement system like the one in Wild Savannah. I don’t have much experience in making custom movement system, so to be honest i have no idea on where to start.
I’ve Tried disabling the A and D keys for movement and then using AngularVelocity to turn the character, but that did not work nicely. Also I tried messing with AlignOrientation to keep the orientation of the animal and not so that it “Points to the way i am moving” for example if I am looking north and i press D, I Keep looking north but the character goes east.
I would greatly appreciate if someone would have a clue so i could have an idea.
//Recent Strips of Code
--//Sink Keys
local ContextActionService =game:GetService("ContextActionService")
local FowardMovement = Enum.PlayerActions.CharacterForward
local BackwardMovement = Enum.PlayerActions.CharacterBackward
local LeftMovement = Enum.PlayerActions.CharacterLeft
local RightMovement = Enum.PlayerActions.CharacterRight
local function Sink()
return Enum.ContextActionResult.Sink
end
ContextActionService:BindAction("SinkLeftMovement", Sink,false,LeftMovement)
ContextActionService:BindAction("SinkRightMovement",Sink,false,RightMovement)
--//Movement
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local RootPart = Character:WaitForChild("HumanoidRootPart")
--LoadingInAnimations
local LoadedAnimations = {}
for _, v in pairs(Character:WaitForChild("Animations"):GetChildren()) do
LoadedAnimations[v.Name] = Humanoid:LoadAnimation(v)
end
--//Services
local UserInputService = game:GetService("UserInputService")
--Values
local AlingOrientation = RootPart:WaitForChild("AlignOrientation")
local Left = RootPart:WaitForChild("Left")
local Right = RootPart:WaitForChild("Right")
local Turning = false
UserInputService.InputBegan:Connect(function(inpt,gmpr)
print("Pressed")
print(gmpr)
print(inpt.KeyCode.Name)
if inpt.KeyCode == Enum.KeyCode.A and gmpr == true then
Turning = true
AlingOrientation.Enabled = false
Left.Enabled = true
elseif inpt.KeyCode == Enum.KeyCode.D and gmpr == true then
AlingOrientation.Enabled = false
Right.Enabled = true
end
end)
UserInputService.InputEnded:Connect(function(inpt, gmpr)
if inpt.KeyCode == Enum.KeyCode.A and gmpr == true then
Turning = false
AlingOrientation.CFrame = CFrame.new(0,0,0) * CFrame.Angles(math.rad(0),math.rad(RootPart.Orientation.Y), math.rad(0))
AlingOrientation.Enabled = true
Left.Enabled = false
elseif inpt.KeyCode == Enum.KeyCode.D and gmpr == true then
Turning = false
AlingOrientation.CFrame = CFrame.new(0,0,0) * CFrame.Angles(math.rad(0),math.rad(RootPart.Orientation.Y), math.rad(0))
AlingOrientation.Enabled = true
Right.Enabled = false
end
end)