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: Cutscene Question:

Previous Thread :: Next Thread 
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
09 Jun 2012 11:42 AM
I've been using HotThoth's cutscene model, and it works in Build, but on a a server, the camera just moves around the character. It's inside the StarterGui, and there are welds that represent where the camera is moving.

    -- HotThoth's Cutscene Script version 1.0 Beta --
--     It's "Beta" so you can't blame me if it stops working :P


-- *****   How to Use ***** --
-- Before your place is running:
-- 1.] Make a CamTrack model for your cutscene:
--      a.) Copy/paste the frame parts when you need more frames; position them how you want your camera to look (yellow stub points "forwards").
--      b.) It will only rotate up to 180-degrees, so just use more frames when you want more rotation than that
--      c.) Name each of your frames a number, this number says when your camera will be in this position
--      d.) If you want to "Roll" the camera, you need to have a NumberValue object named "Roll" under the camera frame.
--           The value you use for Roll tells it how many rotations it should have made by the time it gets to that frame.
--           It's in radians, so 6.283 is a full 360 from the last frame.
--      e.) Make sure all the frames you want for THIS cutscene are inside of a single model, and that nothing else is in that model.
--           This model is called your CamTrack model. You will have exactly one for each cutscene. It's totally fine to have
--           more cutscenes and more CamTrack models, just name them different things (and set up the camTrack variable correctly in the script below).
-- 2.] Set up your variables in the section below
-- 3.] (optional) When you want to see how the camera moves while in Studio, rename the CamTrack you want to preview to just "CamTrack".
--                 Then you can go to Tools-->Execute Script, choose CamPreview.txt (See below if you don't have it yet), and see the camera go through the path.
--                 After running it once, you can type in the command _G["CamPreview"](showFrames, accel) with showFrames
--                 being either "true" or "false" and accel being the value of "accel" you want to test out (in the variables you set up).
-- 4.] (optional) Change the last few lines of this script to alter what happens after your cutscene is over


-- When your place is running:
-- 4.] Put a copy of this script in one of the following places:
--      a.) The Backpack of the Player who should see the cutscene
--      b.) The PlayerGui of the Player who should see the cutscene
--      c.) The Character of the Player who should see the cutscene
-- 5.] When you want this script to run, set its .Disabled property to false


-- To be able to preview the Camera in Studio:
-- 1.] Make a text file called CamPreview.txt somewhere on your computer.
-- 2.] Copy everything exactly from PreviewScript into that text file.
-- 3.] Save it. Now you have the CamPreview.txt script and can do optional step 3 of "How To Use."


-- *****  Variables you should set-up ***** --

-- camTrack must be set to the model where all of your camera frames are kept!
local camTrack = game.Workspace.CamTrack1

-- 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!
wait(3)
camera.CameraSubject = oldCameraSubject
camera.CameraType = oldCameraType
camera.CoordinateFrame = oldCameraCFrame
camera.Focus = oldCameraFocus

-- *****    End of cutscene over function ***** --











~Let the Flame Wars begin! And may the odds NEVER be in your favor!~
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
09 Jun 2012 12:18 PM
Bump.






~Let the Flame Wars begin! And may the odds NEVER be in your favor!~
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
09 Jun 2012 12:19 PM
This just tells people the script. How are they going to learn how to make their own cutscenes if all you do is give them everything they need to make it out of pure lazyness?

-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]-
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
09 Jun 2012 12:21 PM
Tell that to HotThoth, not me.

Anyway, it isn't just that I insert the script and its finished, no no no. But could you please just answer the question? I need to finish my game :3







~Let the Flame Wars begin! And may the odds NEVER be in your favor!~
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