Need Support with 2D game

So, you don’t want the player to move with the camera?

2 Likes

As I mentioned, I was on mobile, now I am on PC so:

local Camera = workspace.CurrentCamera
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local Position = Vector3.zero
local Speed = 16

RunService.RenderStepped:Connect(function(deltaTime)
	local movementDirection = Vector3.new(UserInputService:IsKeyDown(Enum.KeyCode.A) and -1 or UserInputService:IsKeyDown(Enum.KeyCode.D) and 1 or 0,UserInputService:IsKeyDown(Enum.KeyCode.S) and -1 or UserInputService:IsKeyDown(Enum.KeyCode.W) and 1 or 0,UserInputService:IsKeyDown(Enum.KeyCode.Q) and -1 or UserInputService:IsKeyDown(Enum.KeyCode.E) and 1 or 0)
	
	Position += (movementDirection.Magnitude > 0 and movementDirection.Unit*deltaTime*Speed or Vector3.zero)
	
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = CFrame.new(Vector3.yAxis*100,Vector3.zero)*CFrame.new(Position)
end)
1 Like

Basically, I don’t want the player itself to be seen, but the camera to be manipulated by the player.

It works, almost perfectly as I wanted.

Basically, I don’t want the player itself to be seen, but the player itself to be able to manipulate the camera.

A key: The camera goes to the left
D key: The camera goes to the right
W key: The camera moves forward
S key: The camera goes back

And I also want to add that to lower the camera down or up, use the mouse wheel. If you press the mouse wheel, the camera goes to the side where the cursor is.

So if I press one of the keys (w,a,s,d) then the camera will move, not the player, and the player itself will be invisible, so it will not be seen

I don’t know how to explain exactly but I want it to be that ‘camera manipulating’ like on roblox studio. That is to be able to control your camera as if you were playing in first person, but the camera is floating in the air and that it is not solid so that the camera can fall from the sky

Do you know what I mean now? @lonely1and1afraid @bluechristmas20181

It is not permissible for devforum members to always provide complete code for you. I would explain how it would work but I won’t be providing anymore free code.

Basically you can use UserInputService.InputChanged to see if mousewheel is changed. You need to also have a variable called cameraDistance. You can use input.Position.Z to get the mouseWheel’s delta value and add or subtract the cameraDistance accordingly, then just put the value of the cameraDistance like so:

local movementDirection = Vector3.new(UserInputService:IsKeyDown(Enum.KeyCode.A) and -1 or UserInputService:IsKeyDown(Enum.KeyCode.D) and 1 or 0,UserInputService:IsKeyDown(Enum.KeyCode.S) and -1 or UserInputService:IsKeyDown(Enum.KeyCode.W) and 1 or 0,cameraDistance)
2 Likes

So, I would anchor the player, turn off collision, and make the player invisible.

EDIT: That’s only what I would do, there might be other ways too.

1 Like