Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 27 Jan 2015 05:23 PM |
| Trying to make a 2D game and cant figure that out. |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
|
| 27 Jan 2015 05:57 PM |
| Use a Scriptable camera for everything involving camera manipulation. |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 27 Jan 2015 06:01 PM |
Can I set camera to scriptable then change the angle of it? If I where to do that would it still follow the user around and stay in the same angle? |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 06:02 PM |
| No, so you need to set it every frame with RenderStepped. |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 06:06 PM |
Here's a camera LocalScript:
local cam = workspace.CurrentCamera local plr = game.Players.LocalPlayer local Dist = 10 --How many studs away from char you want the camera to be repeat c = plr.Character until c ~= nil wait() cam.CameraType = "Scriptable"
while wait() do cam:Interpolate(CFrame.new(c.Head.Position+Vector3.new(0, 0, -Dist)), CFrame.new(c.Head.Position), .1) end
Here's a movement LocalScript:
local plr = game.Players.LocalPlayer repeat c = plr.Character until c ~= nil wait() torso = c.Torso local bp = Instance.new("BodyPosition") bp.Name = "TwoD" --Change this to whatever you wish to call the BodyPosition bp.position = torso.Position bp.P = 1000000 bp.D = 1000 bp.maxForce = Vector3.new(0, 0, 1000000) --If you want the player to move at a different Axis, replace a 0 with it, and then replace the original spot with a 0, example: (1000000, 0, 0) bp.Parent = torso
Place them both in LocalScripts and 2D is solved. |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 06:07 PM |
| They both go in StarterGui BTW |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 06:09 PM |
"while wait() do cam:Interpolate(CFrame.new(c.Head.Position+Vector3.new(0, 0, -Dist)), CFrame.new(c.Head.Position), .1) end"
I would just do
game:GetService("RunService").RenderStepped:connect(function() cam.CoordinateFrame = CFrame.new(c.Head.Position+Vector3.new(0, 0, -Dist)) end) |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 06:13 PM |
@Jarod Do you mean cam.CoordinateFrame = CFrame.new(c.Head.Position) * CFrame.new(0, 0, -Dist) |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 06:14 PM |
| It's the same thing actually. |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 06:20 PM |
| @Jarod Interpolate is actually better, due to the fact that you can make the camera "lag" behind a bit :P |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 27 Jan 2015 08:36 PM |
Well I jut needed to disable right click. I have this so far, lol. I'll work something out, Thanks.
local Plr = game.Players.LocalPlayer repeat wait() until Plr.Character local Mouse = Plr:GetMouse() workspace:FindFirstChild(Plr.Name).Humanoid.WalkSpeed = 0 Plr.CameraMaxZoomDistance,Plr.CameraMinZoomDistance = 15,15
Mouse.KeyDown:connect(function(key) if key == "d" or key == "a" then workspace:FindFirstChild(Plr.Name).Humanoid.WalkSpeed = 16 else workspace:FindFirstChild(Plr.Name).Humanoid.WalkSpeed = 0 end end) |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 08:37 PM |
| But the camera won't "Lag" behind when you are using it on the Character. That only happens on parts managed by the server. |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 08:46 PM |
| Interpolation is typically smoother. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 Jan 2015 08:48 PM |
| Jarod, it's not the same thing (referring to .CoordinateFrame = blah posts). What he said would work as one would expect, what you said would work if their rotation was "default" (0). |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 Jan 2015 08:48 PM |
Well, no I'm wrong since I can't read. You both did it wrong, but yes both of yours is the same thing.
camera.CoordinateFrame = head.CFrame * CFrame.new(0, 0, -dist) is the correct way to do it. |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 08:49 PM |
| That's not what I'm saying. If you are setting the camera's position based on just the character or only things dependent on the client, you can just use RenderStepped, because it is as smooth as you can get. |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 08:51 PM |
"Trying to make a 2D game" >Implies camera doesn't rotate
And if it is pointing in the wrong direction, he can just rotate the CFrame. But I am assuming he doesn't want it moving with the character. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 Jan 2015 08:52 PM |
Ahh, well you see some people like myself only read the title and the replies... I'm a dumb. |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 08:53 PM |
I only read the title and parts of the post, maybe a few replies by favorite people (cntkillme, eLunate, 128GB)
It's really weird that way. :\ |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 08:54 PM |
local plr = game.Players.LocalPlayer repeat wait() until plr.Character local char = plr.Character local hum = char:WaitForChild("Humanoid") local bpos = Instance.new("BodyPosition") local cam = game.Workspace.CurrentCamera local m2d = false bpos.maxForce = Vector3.new(math.huge,0,0) bpos.position = Vector3.new(0,0,0) cam.CameraType = "Scriptable"
plr:GetMouse().Button2Down:connect( function() m2d = true end ) plr:GetMouse().Button2Up:connect( function() m2d = false end )
game:GetService('RunService').Heartbeat:connect( function() if m2d then return false end cam:Interpolate(CFrame.new(char.PrimaryPart.Position +Vector3.new(0,0,15)),char.PrimaryPart.CFrame,0.1) end ) |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 27 Jan 2015 08:55 PM |
Let's say I do this, Is there a way to make the angle point at the player?
game:GetService("RunService").RenderStepped:connect(function() Cam.CoordinateFrame = CFrame.new(workspace[Plr.Name].Head.Position) * CFrame.new(0, 0, -10) * CFrame.Angles(0, 0, 0) end)
No matter what I put in CFrame.Angles it does not go where I need it to, It stays behind the user. |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 27 Jan 2015 08:58 PM |
Cam:Interpolate(CFrame.new(workspace[Plr.Name].Head.Position + Vector3.new(0,0,15)),workspace[Plr.Name].Head.CFrame,0.1)
Worked perfect, thanks. Can I also add an angle to this and make in somewhat looking down on the user? |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2015 09:02 PM |
| You are supposed to rotate BEFORE you move the camera away -_- |
|
|
| Report Abuse |
|
|