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!
So as I am currently creating a game I think the 3rd person kinda camera would be really nice in this situation.
Currently I have no idea how to make this, I’ve tried looking at some other posts but none of them really work, either that or they only support PC.
Now I do actually have some code already. But it doesnt support Mobile or console, im not exactly sure how to do it. Id have to figure out how to tell where when the players swipes to the side or up on mobile or whatever and move it into place, and for console something with the joystick thingy. Ofc I dont know how to do any of those things. So if you could help me learn how I can do that, it would be very helpful! Thanks!
--|| SERVICES ||--
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
--|| VARIABLES ||--
local Camera = workspace.Camera
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local CameraAngleX, CameraAngleY = 0,0
local CameraCFrame,CameraFocus,StartCFrame
local CameraOffset = Vector3.new(1,3,9.5)
local Movement = Enum.UserInputType.MouseMovement
RunService.RenderStepped:Connect(function()
if Camera.CameraType ~= Enum.CameraType.Scriptable then
Camera.CameraType = Enum.CameraType.Scriptable
end
StartCFrame = CFrame.new((HumanoidRootPart.CFrame.Position)) * CFrame.Angles(0, math.rad(CameraAngleX), 0) * CFrame.Angles(math.rad(CameraAngleY), 0, 0)
CameraCFrame = StartCFrame:ToWorldSpace(CFrame.new(CameraOffset.X, CameraOffset.Y, CameraOffset.Z))
CameraFocus = StartCFrame:ToWorldSpace(CFrame.new(CameraOffset.X, CameraOffset.Y, -10000))
Camera.CFrame = CFrame.new(CameraCFrame.Position, CameraFocus.Position)
--|| Rotating the Character with mouse ||--
--HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position) * CFrame.Angles(0, math.rad(CameraAngleX), 0)
end)
UserInputService.InputBegan:Connect(function(InputObject)
local UserInputType = InputObject.UserInputType
if UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCenter then
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
end
end)
UserInputService.InputChanged:Connect(function(InputOject)
local UserInputType= InputOject.UserInputType
if(UserInputType== Movement)then
local Delta = InputOject.Delta
CameraAngleX = CameraAngleX-Delta.X
CameraAngleY = math.clamp(CameraAngleY-Delta.Y, -75, 75)
end
end)