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: Return the camera.

Previous Thread :: Next Thread 
Kasumo is not online. 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 is not online. 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 is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
21 Aug 2013 08:05 PM
It didn't work.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
21 Aug 2013 08:05 PM
What did you do the camera already?
Report Abuse
Kasumo is not online. 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
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
21 Aug 2013 08:09 PM
Break the loop.
Report Abuse
Kasumo is not online. 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 is not online. 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 is not online. 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 is not online. 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
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
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
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
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 is not online. 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 is not online. Kasumo
Joined: 22 Mar 2013
Total Posts: 2467
21 Aug 2013 08:25 PM
Bump.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
21 Aug 2013 08:26 PM
...Do you really need to bump this?

No, you don't.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
21 Aug 2013 08:27 PM
http://www.lua.org/pil/4.4.html
Report Abuse
cntkillme is not online. 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
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
21 Aug 2013 08:29 PM
Numeric.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
21 Aug 2013 08:30 PM
Then why do people use pairs?
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
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 is not online. 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
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
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 is not online. 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
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
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
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