Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 21 Aug 2013 08:02 PM |
How do I return the camera back to its original position?
while wait() do camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, angle, 0) * CFrame.new(0, 0, -8) angle = angle + math.rad(1) end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 21 Aug 2013 08:02 PM |
Just do:
camera.CameraType = "Custom" camera.CameraSubject = Game.Players.LocalPlayer.Character.Humanoid |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
|
| 21 Aug 2013 08:05 PM |
| What did you do the camera already? |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 21 Aug 2013 08:06 PM |
This:
local target = player.Character.Torso local camera = workspace.CurrentCamera camera.CameraSubject = target local angle = 0 while wait() do camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, angle, 0) * CFrame.new(0, 0, -8) angle = angle + math.rad(1) end
But when I try to return the camera it keeps rotating. |
|
|
| Report Abuse |
|
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 21 Aug 2013 08:12 PM |
The problem is that I would need to break it through another thread. E.g.
if Key == "z" then script.Code.Value = 2 local target = player.Character.Torso local camera = workspace.CurrentCamera camera.CameraSubject = target local angle = 0 while wait() do camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, angle, 0) * CFrame.new(0, 0, -8) angle = angle + math.rad(1) end elseif script.Code.Value == 2 then --Break the loop script.Code.Value = 1 end end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 21 Aug 2013 08:14 PM |
"break" put the while loop in a Spawn, Delay, or coroutine. |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 21 Aug 2013 08:15 PM |
| ?, ?, and I don't know how to use those. :3 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 21 Aug 2013 08:16 PM |
for i = 1, 10 do print(i) if i == 3 then break end end
>>1 >>2 >>3 |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2013 08:16 PM |
for i = 1, 10 do if i == 3 then break end print(i) end print'DONE'
>1 >2 >3 >DONE
BTW: I mostly use RunService.Stepped for loops and disconnect the connection when I want to break it. |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2013 08:17 PM |
Wow, we had the same idea
But cnt's is more working; mine would not print '3' (I wasn't going to include the print and added it at the last minute xP) |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 21 Aug 2013 08:18 PM |
| Where do I put that..Inside of the second thread? |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
|
| 21 Aug 2013 08:26 PM |
...Do you really need to bump this?
No, you don't. |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2013 08:27 PM |
| http://www.lua.org/pil/4.4.html |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 21 Aug 2013 08:29 PM |
Numberic for vs Generic for Which is faster c: |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 21 Aug 2013 08:30 PM |
| Then why do people use pairs? |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2013 08:31 PM |
People should use next
And because its nice and sets the variable, and can be used on tables with non-numeric indexes, or tables with gaps in the indexes. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 21 Aug 2013 08:33 PM |
| next is slower then pairs, and pairs can grab non-numeric indexes, |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2013 08:37 PM |
This is the "pairs" function:
function pairs(table) return next, table, nil end
Its actually slower. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 21 Aug 2013 08:38 PM |
| But it was tested, and it came out slower but 0.003 almost every time. |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2013 08:40 PM |
I found this on some forum after a quick google:
"They are in fact the same (C) function, no differences between them. They are registered on the Lua side twice though, with two different closures and thus two different addresses. Both immediately feed to the same C function, although there's no way of programmatically detecting that from within a script (without debug cheating, afaik)." |
|
|
| Report Abuse |
|
|