You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear! I’m trying to build a camera system where the user can click arrows on the left and right to rotate the view by 90 degrees and can click a forward-facing arrow to move forward, but only if there’s a node there.
My issue is that I have no idea how to do this. My current system checks the direction the camera is facing, then offsets it by 10 studs, and checks if there’s a camera anchor BasePart in that location in a specific folder for these camera BaseParts. But that limits me to a 10-stud grid. How can I make this better? An idea I had was to have a folder of such BaseParts but to name them their grid coordinate position so I don’t have to rely on workspace.
You can programme this using the camera CFrame. The camera you are playing with can be accessed by doing workspace.CurrentCamera and it’s CFrame is where it is located and where it is facing. Just modify it. If you don’t know how to do this then look at this documentation about it CFrame.
Yeah, but I mean more the programming theory behind how to organize a camera manager like that. Like, I want the camera to only be in certain nodes, I don’t want it to be able to go anywere.
Like I mentioned, my current system uses a grid of BasePart nodes. The downside is that I’m limited to a 10x10stud grid and I want to have more flexibility than that
I would probably just put all of the positions you want the camera to be able to go to in a table and later on look up if the position you want to go to is in there. I would just do a table look up. Unless you want an extremely large amount of places/nodes you want your camera to be able to go to.
I didn’t do 90 degree rotations, but I’m sure the system could be adapted to it.
Each pink hitbox is linked to a camera, clicking your mouse in the area of the pink hitbox will take you to the camera it’s linked to.
All you have to do is create the camera and create the hitbox.
I set the possible camera positions (white) and created clickable “hitboxes” (pink).
Each camera comes with its own settings: What music to play? angle limits? currently disabled (hitboxes will not trigger)? Extra code to run? Also this was before attributes were a thing so you should definitely use attributes now.
If you are procedurally generating this or want to automate it, you can create a camera object and spawn a huge hitbox outside of it (the reason why my camera isn’t the hitbox itself is because the game needed multiple hitboxes for some cameras).
I don’t know exactly what game you’re doing. I can only assume a point and click game. Setting it up this way has multiple advantages to the application:
non scripters can also use it without technical knowledge
you can “fork” an area, like having 2 doors within view instead of the rigid 1 pathway per rotation
there’s room for expansion later down the line when you need to add more settings to the room/camera
Regarding this, you could possibly detect a pink hitbox within view by raycasting the center of the screen, or using Camera:WorldToScreenPoint with a raycast check.
I realy like the way this looks and think it could fit well.
But, when you say “take you to the camera it’s linked to” does that mean you’re storing the camera CFrame in the part, or is there some camera instance that I don’t know about that you have inside of the parts that the player’s camera is assigned to?
The camera’s CFrame is set directly to the white part’s CFrame ie inside the part. The player can then start from that origin CFrame and rotate left and right on receiving player input.
This is a skeleton of how it’s done:
local targetPartCF = -- cframe of the white part
local angle = 0
userinput:Connect(function(input)
if input == "Left" then
angle += 1
elseif input == "Right" then
angle -= 1
end
end)
runservice.RenderStepped:Connect(function()
camera.CFrame = targetPartCF * CFrame.Angles(0,math.deg(angle),0)
end)