Hi! I want to create a Sandbox game, 2D type, but I want the camera from the player to be seen from above, I don’t want a top-down 2D game, I want it to be seen from above,idk if you know what I exactly mean… That means the camera should be somewhere up and be able to see a larger radius, such as the whole map, and not be able to see the player character itself, and the player to be able to move forward, further back, left, right, lower, higher.
An example of a game outside of Roblox,that describes my situation, is Brawl Stars or Clash Royale
Could you help me how to code this? And tell me the exact name of this game I want to make?
I don’t know for sure what a 2.5D game is. But I think you know the game clash royale or brawl stars, well when you enter a match on brawl stars or clash royale your camera is fixed somewhere up and you can see 2D but ONLY FROM ABOVE. That’s the camera part I want.Also i want to be able to go with the camera left, right, front, back and up and down
I dont have access to studio right now, but try this;
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local CAMERA_DISTANCE = 15
local CAMERA_HEIGHT = 10
local function updateCamera()
if character and character:IsDescendantOf(game) then
local characterPos = character.Position
local cameraOffset = Vector3.new(0, CAMERA_HEIGHT, -CAMERA_DISTANCE)
local cameraPos = characterPos + cameraOffset
game.Workspace.CurrentCamera.CFrame = CFrame.new(cameraPos, characterPos)
end
end
humanoidRootPart:GetPropertyChangedSignal("Position"):Connect(updateCamera)
updateCamera()
Try this in a local script in StarterPlayerScripts.
humanoid:GetPropertyChangedSignal("Position")? You made a mistake here…
I would suggest OP to use RunService, as it’s more reliable and better overall.
To OP:
Are you trying to make a 2d plane game but have the camera see a large area of the screen or something else? Can you please explain by making a diagram?
No,i don’t want to make a plane game.I want to make a sandbox game,to create your empire and army and protect the city.And I want to make the game 2D and be able to manipulate the Camera(go:Forward,Backward,right,left go down(not be able to go below the map),and go up.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local CAMERA_DISTANCE = 15
local CAMERA_HEIGHT = 10
local function updateCamera()
if character and character:IsDescendantOf(game) then
local characterPos = character.Position
local cameraOffset = Vector3.new(0, CAMERA_HEIGHT, -CAMERA_DISTANCE)
local cameraPos = characterPos + cameraOffset
game.Workspace.CurrentCamera.CFrame = CFrame.new(cameraPos, characterPos)
end
end
gamw:GetService("RunService").RenderStepped:Connect(updateCamera)
updateCamera()
local player = game.Players.LocalPlayer
player.CharacterAdded:Wait()
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local CAMERA_DISTANCE = 15
local CAMERA_HEIGHT = 10
local function updateCamera()
if character and character:IsDescendantOf(game) then
local characterPos = character.Head.Position
local cameraOffset = Vector3.new(0, CAMERA_HEIGHT, -CAMERA_DISTANCE)
local cameraPos = characterPos + cameraOffset
game.Workspace.CurrentCamera.CFrame = CFrame.new(cameraPos, characterPos)
end
end
gamw:GetService("RunService").RenderStepped:Connect(updateCamera)
updateCamera()
Ah, I see. You can use UserInputService to see key presses and add or subtract the cameras position accordingly. I don’t have access to y computer so I am not able to provide full code but here is a basic idea:
movementDirection = UserInputService:IsKeyDown(Enum.KeyCode.A) and -1 or UserInputService:IsKeyDown(Enum.KeyCode.D) and 1 or 0,0,UserInputService:IsKeyDown(Enum.KeyCode.S) and -1 or UserInputService:IsKeyDown(Enum.KeyCode.W) and 1 or 0
camera.CFrame *= CFrame.new(movementDirection)
P.S please fix any errors as it’s almost impossible to type code on mobile.
@awry_y and @bluechristmas20181 What should I do so that the camera is left in the open air, but you can control the camera moving? In which direction does the camera player move? (left, right, down, up, front, back?)I mean the parent of the camera
It kinda work.But i want the camera to be up, so that you can only see the map from above and other things, I don’t want you to be able to see the player itself
Here’s an example how it should look like the final result: