Making camera move with mouse

I dont quite understand the question, but I think you are asking for a size limit on a different axis?

1 Like

No like i unlocked the Y axis but it doesnt move because i think that its locked for example with the X axis you have the

local distance = math.clamp((mousepos-CharacterPosition).Magnitude,0,40) --Side to side

Line right?

Well the Y moves Upwards I think you want the camera to move backwards and forwards right? I unlocked the Z and it looks really good.
I dunno if thats what your looking for though
mousepos = Vector3.new(mousepos.X,CharacterPosition.Y,mousepos.Z)

local distance = math.clamp((mousepos-CharacterPosition).Magnitude,0,40)
This just caps the distance of a vector ( a line )
so it never goes past 40 studs in this case

if you have a tree somewhere in your sudio you can actually see the camera move up as you move your
mouse up the tree with the Y unlocked

2 Likes

Ah okay. Can i also make for example the X axis only goes max 40 and the Z axis 20? how can i add that

I am going to remove the cap on distance and im going to place it on x and z individually

2 Likes

Thank you very much for everything mate!!

1 Like

No problem I hope the game turns out well!

2 Likes

I changed a bit It works a lot better I suggest you change it a lil

I think its both smoother and I think i fixed a lil error

local xCap = 40
	local zCap = 20
	
	local new_vector = mousepos-CharacterPosition
	new_vector = Vector3.new(
		math.clamp(new_vector.X,-xCap,xCap),
		new_vector.Y,
		math.clamp(new_vector.Z,-zCap,zCap)
	)
2 Likes

Hey is there any way to make this work in first person,

I’m trying to get it to work with

Player.CameraMode = Enum.CameraMode.LockFirstPerson

but it doesn’t work, its really buggy.

What I want to do is when in first person make the mouse move freely and be able to “look around”

Where should we place that as I also need that.

How do you remove this effect when you click a specific button and when the player dies it is reenabled?

Sorrry, I dont know how to do that. I think its really hard to change first person camera because the mouse is locked.

1 Like

image
Im pretty sure this is where I put the script

1 Like