im trying to debug a little thing im working on, which sets the camera to a fixed angle based on the region of the world the player is in. everything is fine so far, but when moving towards a region, the issue begins
the issue?
lets say you’re walking towards a region still holding “W” the foward movement key, which allows you to enable the fixed angle…
then after that, the camera changes but you’re still holding “W”, since the camera is facing in an alternate direction, your character will also move that way
i dont really like that, because in my opinion i find this to be bad game design and would throw people off if this were to occur during actual gameplay
i’ve tried looking through the devforum for a solution to this issue of mine, but it appears like no one has weird problems unlike me lol
the solution im looking for is to have the player move in the same direction they’re going towards originally, even if the camera has changed it’s direction. if this is possible and you’ve got an answer, please tell me! i’d love to hear it!
This isn’t going to be easy to achieve. I think you would be better off halting character movement and making a tween to show them the new camera, if that applies well to your game?
first you need to fork PlayerModule by press “Play” in-studio and press player find your name and press “PlayerScripts” then Copy “PlayerModule” then press “Stop”
then find “StarterPlayerScripts” and Paste “PlayerModule” we just copied it should look like this
now in your script you need to require ControlModule from LocalPlayer here is my example (You can ignore anything that i don’t commented)
local Region = workspace.Region
local cam = workspace.CurrentCamera
local player = game:GetService("Players").LocalPlayer -- Get Local Player
local PlayerModule = player.PlayerScripts.PlayerModule -- Player Module that we copy and pasted
local ControlModule = require(PlayerModule.ControlModule) -- require ControlModule
local Touched = false
local EndedDelay = 0.5
local CN
local hittedPart
Region.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if Touched then
return
end
hittedPart = hit
Touched = true
ControlModule:SetRelativeCamera(false) -- Don't move character Relative to Camera (Custom Function that we make)
task.wait()
cam.CameraType = Enum.CameraType.Scriptable
CN = game:GetService("RunService").Heartbeat:Connect(function()
cam.CFrame = (hit.Parent.HumanoidRootPart.CFrame + hit.Parent.HumanoidRootPart.CFrame.RightVector * 20) * CFrame.Angles(0, math.rad(90),0)
end)
end
end)
Region.TouchEnded:Connect(function(EndedPart)
if EndedPart ~= hittedPart then
return
end
CN:Disconnect()
hittedPart = nil
cam.CameraType = Enum.CameraType.Custom
ControlModule:SetRelativeCamera(true) -- move character Relative to Camera (Custom Function that we make)
task.wait(2)
Touched = false
end)
I’m making a selfie stick, and I used the following code:
local WS = game:GetService('Workspace')
local cam = WS.CurrentCamera
local tool = script.Parent
local camPosition = tool:WaitForChild('CamPosition')
local equipped = false
local Players = game:GetService('Players')
local player = Players.LocalPlayer
local StarterPlayer = game:GetService("StarterPlayer")
local RunService = game:GetService('RunService')
local function toBind()
cam.CFrame = camPosition.CFrame
end
tool.Equipped:Connect(function()
cam.CameraType = Enum.CameraType.Scriptable
cam.CameraSubject = camPosition
RunService:BindToRenderStep("CameraBind", 1, toBind)
end)
tool.Unequipped:Connect(function()
RunService:UnbindFromRenderStep("CameraBind")
cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = player.Character:WaitForChild("Humanoid")
end)
The issue is, changing the camera’s subject and type bugs the player movement when the player tries to move, it’s weird. When they move backwards (Press W): They start rotating like hell When they move towards camera (Press S): There is a slight curve in movement
So, If I use the method you provided, movement becomes relative to world while I still wanted it relative to camera but not buggy. I was thinking it’ll be fixed If i change the movement of player to be relative to a part directly in front of the player.
as for this you could disable Humanoid [AutoRotate] I am not sure if camera moving along with animations is intended effect for you or not but here is result.