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 » Scripting Helpers
Home Search
 

Re: Detecting camera movement?

Previous Thread :: Next Thread 
Cataphract is not online. Cataphract
Joined: 03 Sep 2008
Total Posts: 112
07 Jan 2014 03:56 PM
It's a bit tricky to explain.
Basically I have a loop and I would like it to tell me when the camera is moving up or down and left or right, for example;
(If player looks up with camera)
CamY=1
(If player looks down with camera)
CamY=-1
(If player looks left with camera)
CamX=-1
(If player looks right with camera)
CamX=1
Report Abuse
Cataphract is not online. Cataphract
Joined: 03 Sep 2008
Total Posts: 112
07 Jan 2014 04:21 PM
Bump
Report Abuse
Cataphract is not online. Cataphract
Joined: 03 Sep 2008
Total Posts: 112
07 Jan 2014 04:58 PM
Bump...
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
07 Jan 2014 05:14 PM
Kind of an interesting question, but a bit of physics will do the trick.

local ax, ay, az = 0, 0, 0
local camera = Workspace.CurrentCamera
local neworg;
local direcs = {['left'] = false, ['up'] = false, ['down'] = false, ['right'] = false, ['forward'] = false, ['back'] = false}

camera.Changed:connect(function(p)
if (p == 'Focus') then
neworg = camera.Focus
local x, y, z = neworg:toEulerAnglesXYZ()

if (ax - x > 0) then direcs['left'], direcs['right'] = true, false end
if (ax - x < 0) then direcs['right'], direcs['left'] = true, false end
if (ay - y > 0) then direcs['down'], direcs['up'] = true, false end
if (ay - y < 0) then direcs['up'], direcs['down'] = true, false end
if (az - z > 0) then direcs['forward'], direcs['back'] = true, false end
if (az - z < 0) then direcs['back'], direcs['forward'] = true, false end

ax, ay, az = x, y, z
end
end)

Intentionally inefficient.
Report Abuse
PiggyJingles is not online. PiggyJingles
Joined: 13 Jan 2009
Total Posts: 2472
07 Jan 2014 05:15 PM
Looked at that and I was like, Absurdism, did you hit your head or something. Saw the ending though. :P
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
07 Jan 2014 05:16 PM
You should know my actual programming style by now.
Report Abuse
wubbzy301 is not online. wubbzy301
Joined: 15 May 2010
Total Posts: 1188
07 Jan 2014 05:19 PM
That was I thinking for.
Report Abuse
Cataphract is not online. Cataphract
Joined: 03 Sep 2008
Total Posts: 112
07 Jan 2014 05:25 PM
I'm not sure how I would convert that into a readable format similar to what I described though.
If I print ax,ay,az it just says 0,0,0 and if I print direcs I get a table.
I'm only an average scripter so forgive my ignorance.
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
07 Jan 2014 05:29 PM
local ax, ay, az = 0, 0, 0
local camera = Workspace.CurrentCamera
local neworg;
local direcs = {['left'] = false, ['up'] = false, ['down'] = false, ['right'] = false, ['forward'] = false, ['back'] = false}

camera.Changed:connect(function(p)
if (p == 'Focus') then
neworg = camera.Focus
local x, y, z = neworg:toEulerAnglesXYZ()

if (ax - x > 0) then direcs['left'], direcs['right'] = true, false end
if (ax - x < 0) then direcs['right'], direcs['left'] = true, false end
if (ay - y > 0) then direcs['down'], direcs['up'] = true, false end
if (ay - y < 0) then direcs['up'], direcs['down'] = true, false end
if (az - z > 0) then direcs['forward'], direcs['back'] = true, false end
if (az - z < 0) then direcs['back'], direcs['forward'] = true, false end

ax, ay, az = x, y, z

-- the only efficient part of the script
for _,v in next,direcs do
print(_, v)
end
end
end
end)
Report Abuse
Cataphract is not online. Cataphract
Joined: 03 Sep 2008
Total Posts: 112
07 Jan 2014 05:45 PM
The script says there is a missing bracket, but I don't see where that is here...
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
07 Jan 2014 05:48 PM
remove the penultimate end
Report Abuse
Cataphract is not online. Cataphract
Joined: 03 Sep 2008
Total Posts: 112
07 Jan 2014 06:03 PM
Lol nothing prints when I look around with the camera, I am a fail at understanding this.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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