generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Preventing the camera from looking up at a certain angle

Previous Thread :: Next Thread 
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 12:27 AM
Well hi. I need to limit the angle at which the camera can look up at, and so I'd like to know how to go about this.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 12:34 AM
I feel like a top quality nub to be asking this. Oh well.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 12:57 AM
This is what I have right now. Works fine, the only problem is that it resets the camera instead of just decreasing it by how much extra angle there is (if that makes sense)

if c.CoordinateFrame.lookVector.Y>0.9 then
local difference=c.CoordinateFrame.lookVector.Y-0.9
print(difference)
c.CoordinateFrame=CFrame.new(Vector3.new(c.CoordinateFrame-Vector3.new(0, difference, 0)))
end
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 01:46 AM
b
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 02:06 AM
Another bump..
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
05 Jul 2015 02:50 AM
What does Difference print?

(I might not be able to help because I don't have as much experience in Camera Manipulation, but I'll try).

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 03:09 AM
I would tell you but Avast detected ROBLOX Studio as malicious and cleared all my Studio stuff saved to my PC, FML.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 03:21 AM
0.037
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
05 Jul 2015 03:33 AM
I thought maybe

local cam=game.Workspace.CurrentCamera
cam.Changed:connect(function()
cam.CoordinateFrame=CFrame.new(Vector3.new(0,cam.CoordinateFrame.lookVector.Y,0))
end)
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 03:36 AM
That just makes it stuck inside the floor
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 03:40 AM
I have also tried this, exact same problem. So I'm beginning to think it's something wrong I'm doing with the lookvectors, or something

if c.CoordinateFrame.lookVector.Y>0.9 then
local difference=c.CoordinateFrame.lookVector.Y-0.9
print(c.CoordinateFrame.lookVector.Y)
print(difference)
c.CoordinateFrame=CFrame.new(Vector3.new(c.CoordinateFrame.X, 0.8, c.CoordinateFrame.Z))
end
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 04:05 AM
61 views lol.
Report Abuse
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
05 Jul 2015 05:51 AM
This has an annoying bug, but the main concept is there:

local cam = workspace.CurrentCamera
local maxAngle = 110

game["Run Service"].RenderStepped:connect(function ()
local curCFrame = cam.CoordinateFrame
local curAngle = math.deg(math.acos(curCFrame.lookVector:Dot(Vector3.new(0, -1, 0))))
if curAngle > maxAngle then
cam:TiltUnits((curAngle - maxAngle)/10)
end
end)
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
05 Jul 2015 07:03 AM
try CFrame.new() instead of Vector3.new() they make a huge difference...

"My Life is going Good... but..."
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 03:38 PM
@Kapit

"Vector3 expected, got userdata"

Thank you buildersteve

Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 03:39 PM
Now all there is to do is to get the camera not to be stuck again, ;(
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
05 Jul 2015 03:41 PM
em, am sure u didn't do it correctly...
I don't think u can do CFrame - CFrame...
do this...

TheCFrame * CFrame.new(0, -difference, 0)

"My Life is going Good... but..."
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
05 Jul 2015 03:42 PM
oops...
meant * CFrame.Angles(0, -difference, 0)
cos I think u said look UP not be POSITIONED up...

"My Life is going Good... but..."
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 03:46 PM
I've already tried that. Same issue, the camera completely resets.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
05 Jul 2015 04:00 PM
hmmm :/

"My Life is going Good... but..."
Report Abuse
lucas200206 is not online. lucas200206
Joined: 06 Dec 2009
Total Posts: 899
05 Jul 2015 04:03 PM
DrMathemathica (I think now he is MrNicNac) told me the solution a while ago, I will see if I can find it.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 04:04 PM
At least this question is less noobish than I thought. That would be great if you could find it.

Thanks for the help everyone
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
05 Jul 2015 04:34 PM
This is your solution:

local Camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local CameraThreshold_Theta = 60
local Abs = math.abs

RunService.RenderStepped:connect(function()
local CameraPitch = math.deg(math.asin(Camera.CoordinateFrame.lookVector.Y))
if (Abs(CameraPitch) > CameraThreshold_Theta) then
local DesiredAngleChange = (CameraPitch < 0 and math.abs(CameraThreshold_Theta + CameraPitch)) or (CameraThreshold_Theta - CameraPitch)
Camera.CoordinateFrame = Camera.CoordinateFrame * CFrame.fromAxisAngle(Vector3.new(1,0,0), math.rad(DesiredAngleChange))
end
end)
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
05 Jul 2015 04:35 PM
However, I'd just recommend making your own camera controls, because working like that with a ROBLOX camera type can just be unnaturally choppy.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Jul 2015 04:40 PM
Odd. Same problem again, my friend the camera gets stuck.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image