|
| 27 Dec 2016 07:09 AM |
Lets hope ROBLOX doesn't censor this entire thing. I'm attempting to make a 2 dimensional game, where the camera is facing down above your character. I've been attempting to manipulate to have this happen, but have not been successful. Here's my script so far, which I think is working just the angle of the camera is wrong;
local cam = workspace.CurrentCamera local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local char = plr.Character local tor = char.Torso local body = Instance.new('BodyPosition',tor) body.MaxForce = Vector3.new(0, 0, math.huge) body.Position = Vector3.new(0, plr.Character.Torso.Position.Y, 0)
cam.CameraType = Enum.CameraType.Scriptable cam.CameraSubject = tor
game:GetService("RunService").RenderStepped:connect(function() cam.CFrame = CFrame.new(plr.Character.Torso.CFrame.X, plr.Character.Torso.CFrame.Y + 10, plr.Character.Torso.CFrame.Z) cam.FieldOfView = 80 end)
I think I'm more or less just asking how do I aim the camera down. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2016 07:10 AM |
| directly after posing a realized I forgot to say that this is a local script in game.StarterPlayer.StarterPlayerScripts |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 27 Dec 2016 07:43 AM |
-- put this in the StarterGui
local player = game.Players.LocalPlayer local char = player.CharacterAdded:wait() local cam = workspace.CurrentCamera local camHeight = 20 -- how high above the torso?
RunService:BindToRenderStep("BeforeCamera", Enum.RenderPriority.Camera.Value-1, function() local offset = char.Torso.CFrame*CFrame.new(0,camHeight,0) -- offset from the torso cam.CFrame = offset * CFrame.new(cam.CFrame.p,char.Torso.CFrame.p)-- look at the torso end)
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 27 Dec 2016 07:49 AM |
There was a lot wrong with that ^ Use this:
local player = game.Players.LocalPlayer local char = player.CharacterAdded:wait() local cam = workspace.CurrentCamera cam.CameraType = Enum.CameraType.Scriptable local camHeight = 50 -- how high above the torso?
game:GetService("RunService"):BindToRenderStep("BeforeCamera", Enum.RenderPriority.Camera.Value-1, function() local offset = char.HumanoidRootPart.CFrame*CFrame.new(0,camHeight,0) -- offset from the torso cam.CFrame = CFrame.new(offset.p,char.HumanoidRootPart.CFrame.p)-- look at the torso end)
|
|
|
| Report Abuse |
|
|
|
| 27 Dec 2016 09:11 AM |
that's not what I meant, I meant something that puts the camera directly above the character and faces the camera down on the torso, is that possible? |
|
|
| Report Abuse |
|
|
OAuth2
|
  |
| Joined: 27 Nov 2016 |
| Total Posts: 751 |
|
|
| 27 Dec 2016 09:18 AM |
cam.CoordinateFrame = CFrame.new(x, y, z) * CFrame.Angles(x, y, z)
note that x, y, z for angles needs to be in radians. (math.rad(#))
|
|
|
| Report Abuse |
|
|
|
| 27 Dec 2016 09:28 AM |
ughh being a noob sucks even though I've been scripting for years... can you post a script that just makes the camera 10 studs above the player, and aiming down at him/her? that'd be huge. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 27 Dec 2016 09:28 AM |
That's what this script does, no? I tested it myself. It was above the character by 50 studs and pointed towards the torso always. Do you want the camera locked in one place?
|
|
|
| Report Abuse |
|
|
|
| 27 Dec 2016 09:33 AM |
Oh, it is, yeah, sorry one of my other ones I was trying to make sense of from the free models was interfering with it, thanks <3 |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2016 09:35 AM |
| one thing is I don't want people to be able to zoom out with the scroll button, is there something I can do about that? |
|
|
| Report Abuse |
|
|