|
| 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 |
|
|
| |
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 15 May 2010 |
| Total Posts: 1188 |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 2568 |
|
|
| 07 Jan 2014 05:48 PM |
| remove the penultimate end |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|