I need help making a 2D fighting game but I cant figure out the camera mechanics,
When two players are close together the camera is close to them.
When two players are far away the camera would zoom out to keep them in the camera.
I need help making a 2D fighting game but I cant figure out the camera mechanics,
When two players are close together the camera is close to them.
When two players are far away the camera would zoom out to keep them in the camera.
how about checking magnitudes of both of their positions and do calculations for the camera position?
one way you could approach it is,
PS :
sorry i couldn’t give you a script i just didn’t have time to script a whole system, hopefully this helps
Oh lol
Glad i could help
I’m excited to see this game when it’s released
can i have the name?
It’d be a 2D street fighter remake so it’d probably be like “Street Bloxer”
Heres the code I have so far by the way but i’m having trouble making a barrier for the camera to stop going out of bounds like you said
local player = game.Players.LocalPlayer
local character = player.Character
local camera = workspace.Camera
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
RunService.RenderStepped:connect(function()
local Part = workspace.Part
local magnitude = (Part.Position - character.HumanoidRootPart.Position).Magnitude
local middlePos = (Part.Position+character.PrimaryPart.Position)/2
local goal = {}
goal.CFrame = CFrame.new(middlePos) + Vector3.new(0, 0, magnitude)
if goal.CFrame.X > 25 then -- trying to add a barrier
print('too far')
end
local tweenInfo = TweenInfo.new(1)
local tween= TweenService:Create(camera,tweenInfo,goal)
tween:Play()
end)
Figured it out!
local player = game.Players.LocalPlayer
local character = player.Character
local camera = workspace.Camera
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
RunService.RenderStepped:connect(function()
local Part = workspace.Part
local magnitude = (Part.Position - character.HumanoidRootPart.Position).Magnitude
local middlePos = (Part.Position+character.PrimaryPart.Position)/2
camera.CameraType = Enum.CameraType.Scriptable; --so script can change it
local goal = {}
goal.CFrame = CFrame.new(middlePos) + Vector3.new(0, 0, magnitude)
if CFrame.new(middlePos).X > 40 then
goal.CFrame = CFrame.new(0,10,30)
elseif CFrame.new(middlePos).X < -40 then
goal.CFrame = CFrame.new(0,10,30)
else
goal.CFrame = CFrame.new(middlePos) + Vector3.new(0, 0, magnitude)
end
local tweenInfo = TweenInfo.new(1)
local tweeen = TweenService:Create(camera,tweenInfo,goal)
tweeen:Play()
end)
Wow good job,
again im really glad i could help
I’m guessing you’re trying to make one of those 2D games. I wish you good luck.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.