|
| 27 Jul 2015 03:43 AM |
local Player = game:GetService("Players").LocalPlayer local Menu = script.Parent local Play = Menu:WaitForChild("Play")
local radius = 7 -- distance from Humanoid Head local angleFromHorizon = 5 --// angle from x-z plane to look at player local angularSpeed = (2*math.pi)/5 --// divide by total time in seconds per revolution --// i.e. (2*math.pi)/5 requires 5 seconds to rotate a full 360 degrees (2pi radians) about the character local player = game:GetService("Players").LocalPlayer --// get player local loopCamera = true --// boolean set this to false when you want the camera to stop
function LoopStop() loopCamera = false end
local head = (wait() and player.Character or player.CharacterAdded:wait()):WaitForChild("Head") --// this is logically equivalent to: --[[ local head do wait() --// give roblox time to load new characters; makes sure we don't grab a previous character when respawning local character = player.Character if character == nil or character == false then --// we didn't find a character! character = player.CharacterAdded:wait() --// waits until a character is added and stores the reference end head = character:WaitForChild("Head") end
--// the do end block creates a seperate scope, so once we block finishes the rest --// of the script won't be able to use the 'character' variable --]]
local rot = CFrame.new() --// how much we have already rotated about the player while loopCamera do local tock = tick() game:GetService("RunService").RenderStepped:wait() workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable --// player no longer can control camera rot = rot*CFrame.Angles(0, angularSpeed*(tick()-tock), 0) --// multiply previous rotation with rotation step for this frame (radians_per_second*seconds == angularchange) workspace.CurrentCamera.CoordinateFrame = CFrame.new( CFrame.new(head.Position)*rot* --//center cframe about head position and rotate it Vector3.new( --multiple that by an offset vector to get camera position 0, radius*math.sin(math.rad(angleFromHorizon)), radius*math.cos(math.rad(angleFromHorizon)) ), head.Position) -- we want the new cframe to look at this position end
if loopCamera == false then
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom --// once the loop breaks we give the camera back
end
Play.MouseButton1Down:connect(LoopStop)
|
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 Jul 2015 03:49 AM |
workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid workspace.CurrentCamera.CameraType = Enum.CameraType.Custom |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 03:55 AM |
-- Not Working
local Player = game:GetService("Players").LocalPlayer local Menu = script.Parent local Play = Menu:WaitForChild("Play")
local radius = 7 -- distance from Humanoid Head local angleFromHorizon = 5 --// angle from x-z plane to look at player local angularSpeed = (2*math.pi)/5 --// divide by total time in seconds per revolution --// i.e. (2*math.pi)/5 requires 5 seconds to rotate a full 360 degrees (2pi radians) about the character local player = game:GetService("Players").LocalPlayer --// get player local loopCamera = true --// boolean set this to false when you want the camera to stop
function LoopStop() loopCamera = false end
local head = (wait() and player.Character or player.CharacterAdded:wait()):WaitForChild("Head") --// this is logically equivalent to: --[[ local head do wait() --// give roblox time to load new characters; makes sure we don't grab a previous character when respawning local character = player.Character if character == nil or character == false then --// we didn't find a character! character = player.CharacterAdded:wait() --// waits until a character is added and stores the reference end head = character:WaitForChild("Head") end
--// the do end block creates a seperate scope, so once we block finishes the rest --// of the script won't be able to use the 'character' variable --]]
local rot = CFrame.new() --// how much we have already rotated about the player while loopCamera do local tock = tick() game:GetService("RunService").RenderStepped:wait() workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable --// player no longer can control camera rot = rot*CFrame.Angles(0, angularSpeed*(tick()-tock), 0) --// multiply previous rotation with rotation step for this frame (radians_per_second*seconds == angularchange) workspace.CurrentCamera.CoordinateFrame = CFrame.new( CFrame.new(head.Position)*rot* --//center cframe about head position and rotate it Vector3.new( --multiple that by an offset vector to get camera position 0, radius*math.sin(math.rad(angleFromHorizon)), radius*math.cos(math.rad(angleFromHorizon)) ), head.Position) -- we want the new cframe to look at this position end
if loopCamera == false then workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid workspace.CurrentCamera.CameraType = Enum.CameraType.Custom --// once the loop breaks we give the camera back
end
Play.MouseButton1Down:connect(LoopStop)
|
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 Jul 2015 04:01 AM |
you only check if loopCamera is false once
Play.MouseButton1Click:connect(function() workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid workspace.CurrentCamera.CameraType = Enum.CameraType.Custom end) |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 04:04 AM |
| hmm can you paste the whole code in so i can have more of an exzample |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 Jul 2015 04:09 AM |
function LoopStop() loopCamera = false local plr = game.Players.LocalPlayer local char = plr.Character local hum = char:FindFirstChild("Humanoid") local cam = workspace.CurrentCamera
cam.CameraSubject = hum cam.CameraType = Enum.CameraType.Custom end
-- at the bottom of your script Play.MouseButton1Click:connect(LoopStop) |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 04:13 AM |
-- Still Not Working :/
local Player = game:GetService("Players").LocalPlayer local Menu = script.Parent local Play = Menu:WaitForChild("Play")
local radius = 7 -- distance from Humanoid Head local angleFromHorizon = 5 --// angle from x-z plane to look at player local angularSpeed = (2*math.pi)/5 --// divide by total time in seconds per revolution --// i.e. (2*math.pi)/5 requires 5 seconds to rotate a full 360 degrees (2pi radians) about the character local player = game:GetService("Players").LocalPlayer --// get player local loopCamera = true --// boolean set this to false when you want the camera to stop
function LoopStop() loopCamera = false end
local head = (wait() and player.Character or player.CharacterAdded:wait()):WaitForChild("Head") --// this is logically equivalent to: --[[ local head do wait() --// give roblox time to load new characters; makes sure we don't grab a previous character when respawning local character = player.Character if character == nil or character == false then --// we didn't find a character! character = player.CharacterAdded:wait() --// waits until a character is added and stores the reference end head = character:WaitForChild("Head") end
--// the do end block creates a seperate scope, so once we block finishes the rest --// of the script won't be able to use the 'character' variable --]]
local rot = CFrame.new() --// how much we have already rotated about the player while loopCamera do local tock = tick() game:GetService("RunService").RenderStepped:wait() workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable --// player no longer can control camera rot = rot*CFrame.Angles(0, angularSpeed*(tick()-tock), 0) --// multiply previous rotation with rotation step for this frame (radians_per_second*seconds == angularchange) workspace.CurrentCamera.CoordinateFrame = CFrame.new( CFrame.new(head.Position)*rot* --//center cframe about head position and rotate it Vector3.new( --multiple that by an offset vector to get camera position 0, radius*math.sin(math.rad(angleFromHorizon)), radius*math.cos(math.rad(angleFromHorizon)) ), head.Position) -- we want the new cframe to look at this position end
function LoopStop() loopCamera = false local plr = game.Players.LocalPlayer local char = plr.Character local hum = char:FindFirstChild("Humanoid") local cam = workspace.CurrentCamera
cam.CameraSubject = hum cam.CameraType = Enum.CameraType.Custom end
--// once the loop breaks we give the camera back
Play.MouseButton1Down:connect(LoopStop)
|
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 Jul 2015 04:14 AM |
well i don't have time to read your whole script, so good luck
that should work, i quote from the wiki:
"To return camera control to the player, we need to set the CameraSubject to the character's humanoid, which is the default. This of course, will have to run in a local script. The below code will fix it.
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid game.Workspace.CurrentCamera.CameraType = "Custom"" |
|
|
| Report Abuse |
|
|
| |
|