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: Camera script breaking online

Previous Thread :: Next Thread 
edenojack is not online. edenojack
Joined: 18 Jul 2008
Total Posts: 989
30 May 2012 07:54 AM
I have added the following function to my script. Its meant to move the camera back to the players body (From a menu camera), however, despite it working in offline mode, online mode creates a second outcome where this doesnt work. I have no idea what to do.

function Activate()
if game.Players.LocalPlayer:findFirstChild("Playing").Value == true then
camera.CameraSubject = oldCameraSubject
camera.CameraType = oldCameraType
camera.CoordinateFrame = oldCameraCFrame
camera.Focus = oldCameraFocus
local d = script.LocalScript:clone()
d.Disabled = false
d.Parent = game.Players.LocalPlayer.Character
local k = script.Intro:clone()
k.Disabled = false
k.Parent = game.Players.LocalPlayer.PlayerGui
end
end

game.Players.LocalPlayer.Playing.Changed:connect(Activate)
Report Abuse
edenojack is not online. edenojack
Joined: 18 Jul 2008
Total Posts: 989
30 May 2012 08:30 AM
Any help? Do I need to post the rest of the script?
Report Abuse
Trioxide is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
30 May 2012 08:32 AM
[ Content Deleted ]
Report Abuse
edenojack is not online. edenojack
Joined: 18 Jul 2008
Total Posts: 989
30 May 2012 08:44 AM
Its a bool value added into the player, along side that, this script is added into the player as well. However, befroe jumping to the conclusion that the playing value doesnt exist in time, the playing value is added before this script.
Report Abuse
edenojack is not online. edenojack
Joined: 18 Jul 2008
Total Posts: 989
30 May 2012 09:15 AM
This is an altered script of HotToth's cutscene script. It is only the ending that is altered. I can upload the script in its entirity if you'd like.
Report Abuse
edenojack is not online. edenojack
Joined: 18 Jul 2008
Total Posts: 989
30 May 2012 10:02 AM
local camTrack = game.Workspace.MenuTrack

-- accel (recommended values between .01 and 1) determines how much "ease" there is; higher numbers means it goes more straight from one frame to the next
local accel = .05

-- ***** Don't change variables below this line ***** --




local camFrames = camTrack:GetChildren()
local r = game:GetService("RunService")

function frameTime(frame)
return tonumber(frame.Name)
end

-- extract our camera track info [table.sort is just too cool!]
table.sort(camFrames, function (a, b) return frameTime(a) < frameTime(b) end)

local camRolls = {}
for i = 1, #camFrames do
local newRoll = 0
if camFrames[i]:FindFirstChild("Roll") then
newRoll = camFrames[i].Roll.Value
end
table.insert(camRolls, newRoll)
end

-- make frames invisible (if they weren't already)
for i = 1, #camFrames do camFrames[i].Transparency = 1 end

-- set up the initial camera configuration and store the old one
local LookFrame = camFrames[1].CFrame + camFrames[1].CFrame.lookVector * 20
local camera = game.Workspace.CurrentCamera

local oldCameraType = camera.CameraType
local oldCameraSubject = camera.CameraSubject
local oldCameraFocus = camera.Focus
local oldCameraCFrame = camera.CoordinateFrame

camera.CameraType = "Scriptable"
camera.CoordinateFrame = CFrame.new(camFrames[1].CFrame.p, LookFrame.p)
camera:SetRoll(camRolls[1])

-- set up movement system
local keepMovementThreadAlive = true
local camVelocity = Vector3.new(0, 0, 0)
local camPartVelocity = Vector3.new(0, 0, 0)
local camRollVelocity = 0

local camPartTargetVelocity = Vector3.new(0,0,0)
local camTargetVelocity = Vector3.new(0, 0, 0)

function movementThread ()
local lastTime = r.Stepped:wait()
while keepMovementThreadAlive do
local newTime = r.Stepped:wait()
local deltaT = newTime - lastTime
camVelocity = camVelocity * (1 - accel) + camTargetVelocity * accel
camPartVelocity = camPartVelocity * (1 - accel) + camPartTargetVelocity * accel

lastTime = newTime
LookFrame = LookFrame + deltaT * camPartVelocity
camera.CoordinateFrame = CFrame.new( (camera.CoordinateFrame + deltaT * camVelocity).p, LookFrame.p)
camera:SetRoll(camera:GetRoll() + deltaT * camRollVelocity)
end
end

function toSingleCircle(angle)
while angle > math.pi do angle = angle - math.pi*2 end
while angle < -math.pi do angle = angle + math.pi*2 end
return angle
end

local movementSystem = coroutine.create(movementThread)
coroutine.resume(movementSystem)

-- go through our camTrack now
for i = 1, #camFrames-1 do
local dT = frameTime(camFrames[i+1]) - frameTime(camFrames[i])
camTargetVelocity = (camFrames[i+1].Position - camera.CoordinateFrame.p) / dT
camPartTargetVelocity = ((camFrames[i+1].CFrame.p + camFrames[i+1].CFrame.lookVector * 20) - (camera.CoordinateFrame.p + camera.CoordinateFrame.lookVector * 20)) / dT
camRollVelocity = (camRolls[i+1] - toSingleCircle(camRolls[i])) / dT
camera:SetRoll(toSingleCircle(camRolls[i]))
wait(dT)
end

-- stop movement when done
keepMovementThreadAlive = false



-- ***** Cutscene Over Function ***** --
-- Default end behavior: wait for 3 seconds, then return camera to what it was before
-- Edit the lines below to change what happens AFTER your cutscene ends!
function Activate()
if game.Players.LocalPlayer:findFirstChild("Playing").Value == true then
camera.CameraSubject = oldCameraSubject
camera.CameraType = oldCameraType
camera.CoordinateFrame = oldCameraCFrame
camera.Focus = oldCameraFocus
local d = script.LocalScript:clone()
d.Disabled = false
d.Parent = game.Players.LocalPlayer.Character
local k = script.Intro:clone()
k.Disabled = false
k.Parent = game.Players.LocalPlayer.PlayerGui
end
end

game.Players.LocalPlayer.Playing.Changed:connect(Activate)

-- ***** End of cutscene over function ***** --
Didnt put this on :P sorry
Report Abuse
Trapper4O77 is not online. Trapper4O77
Joined: 03 Aug 2011
Total Posts: 5648
30 May 2012 10:03 AM
Dat a wot o cohdz..
Report Abuse
edenojack is not online. edenojack
Joined: 18 Jul 2008
Total Posts: 989
30 May 2012 10:04 AM
dah iz troo
Report Abuse
Trapper4O77 is not online. Trapper4O77
Joined: 03 Aug 2011
Total Posts: 5648
30 May 2012 10:07 AM
Sooo.... Any output :3
Report Abuse
edenojack is not online. edenojack
Joined: 18 Jul 2008
Total Posts: 989
30 May 2012 10:08 AM
Nope. It works offline, but not on online :/
Report Abuse
CoreHard is not online. CoreHard
Joined: 08 Apr 2012
Total Posts: 109
30 May 2012 10:08 AM
("Playng")

Thats your mistake.
Unless its a direct child.
Report Abuse
edenojack is not online. edenojack
Joined: 18 Jul 2008
Total Posts: 989
30 May 2012 10:33 AM
where is that?
Report Abuse
edenojack is not online. edenojack
Joined: 18 Jul 2008
Total Posts: 989
30 May 2012 11:02 AM
Can anyone help?
Report Abuse
TrainingToTroll is not online. TrainingToTroll
Joined: 27 Oct 2012
Total Posts: 1757
27 May 2014 09:29 PM
LocalScript/ROBLOXBROKEIT (Blame John Anyways)
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
27 May 2014 10:14 PM
why bump a old thread?
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