Camera and Character Movement Issues

intro

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


solution??

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?

1 Like

I am not sure if this is what you want to do

(just to confirm i am on right track)

1 Like

yeah that’s basically what im going for! if possible, may you elaborate what you did to keep the player in the same original direction?

It maybe a little long but here is Step-by-Step

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”

image

then find “StarterPlayerScripts” and Paste “PlayerModule” we just copied it should look like this

image

now open “ControlModule”

image

and scroll down until you reach last function

and paste this below that last function


function ControlModule:SetRelativeCamera(bool)

self.activeController.moveVectorIsCameraRelative = bool

end

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)

If you are confused at any point you can ask me

4 Likes

heck yea, thats exactly what i’ve been looking for! thank you so much!!!

1 Like