as you can see in the video my player turns to the left and right pretty slow, i want it to be instant like this
any help is appreciated
any help is appreciated
I think you mean something like in this game here
if so this is done by turning off auto rotate on the humanoid and then setting the Cframe rotation directly or tweening it fast to face the new direction depending on player input
the rotation should be on 1 axis that game the rotation is X axis but depends on how your levels are layed out
easy way to do this is for say Looking left do
CFrame.new(HRP.CFrame.p, Vector3.new(HRP.CFrame.p.X - 10, HRP.CFrame.p.Y, HRP.CFrame.p.Z))
and looking back right
CFrame.new(HRP.CFrame.p, Vector3.new(HRP.CFrame.p.X + 10, HRP.CFrame.p.Y, HRP.CFrame.p.Z))
Yes this is very old code of mine so its not the best
so i added that code but now all thats happening is my back is facing my camera no matter what i do when i move
no matter what i try i cant get it to work
what is your main axis you are going to use like left to right on the screen?
yep, left to right
what axis though like X or Z axis?
where would i check that? sorry im just getting into stuff like this
in the properties window while dragging your character left to right the way it would move what axis changes on like Origin Position
its on the x axis, moving to the right the x value goes up, going left makes it go down
can you show me the script where it changes direction think you may have them backwards
local player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
local char = player.Character or player.CharacterAdded
local HRP = char:WaitForChild("HumanoidRootPart")
player.Character.Humanoid.AutoRotate = false
local jumping = false
local leftValue, rightValue = 0, 0
local function onLeft(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
leftValue = 1
elseif inputState == Enum.UserInputState.End then
leftValue = 0
end
end
local function onRight(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
rightValue = 1
elseif inputState == Enum.UserInputState.End then
rightValue = 0
end
end
local function onJump(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
jumping = true
elseif inputState == Enum.UserInputState.End then
jumping = false
end
end
local function onUpdate()
if player.Character and player.Character:FindFirstChild("Humanoid") then
if jumping then
player.Character.Humanoid.Jump = true
end
local moveDirection = rightValue - leftValue
player.Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
end
end
RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)
ContextActionService:BindAction("Left", onLeft, true, "a", Enum.KeyCode.Left, Enum.KeyCode.DPadLeft)
ContextActionService:BindAction("Right", onRight, true, "d", Enum.KeyCode.Right, Enum.KeyCode.DPadRight)
ContextActionService:BindAction("Jump", onJump, true, "w", Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)
well in that i don’t see where you are changing the characters rotation but something like this can do it but this is a simple one
Humanoid:GetPropertyChangedSignal('MoveDirection'):Connect(function()
if Humanoid.MoveDirection.X > .5 then
HRP.CFrame = CFrame.new(HRP.CFrame.p, Vector3.new(HRP.CFrame.p.X + 2, HRP.CFrame.p.Y, HRP.CFrame.p.Z))
elseif Humanoid.MoveDirection.X < -.5 then
HRP.CFrame = CFrame.new(HRP.CFrame.p, Vector3.new(HRP.CFrame.p.X - 2, HRP.CFrame.p.Y, HRP.CFrame.p.Z))
end
end)
and the .5 on those are because mobile doesnt go all the way to 1 value sometimes
where would i put this in my script?
nevermind i figured it out, thank you so much for the help!
no problem glad it helped you out