Jump to content

Blast from the past: in-game cut-scene


Rick
 Share

Recommended Posts

 

Was going over some of my LE 2 videos and found this one where I tried to create an in-game cut-scene. This was all done in Lua using coroutines (a Lua feature). I'll have to see in coroutines work in LE 3.1 version because they would allow you to call functions in sequence where they would yield which would continue the main game loop, and come back where they left off each frame. Allowing you to make scripts like:

 

function MyCutScene()
   GoToPoint(0, 0, 0)
   SwitchCamera(camera1)
   PlaySound("speech")
   GoToPoint(10, 0, 10)
end

 

Where GoToPoint() would move a little to the destination, then yield back to the main game loop to show the change, then go back where it was in the function from last frame, and move a little more. It wouldn't actually exit this function until it reached it's point, and then it would go into the other function and switch camera, etc.

 

This is sort of the way we think about in-game cut-scenes, but without coroutines we end up with a ton of booleans and if statements to manage the state of things, which is a mess.

  • Upvote 2
Link to comment
Share on other sites

Looks like they do work with Leadwerks Lua. Now it's just creating some functions that do common things with the yeild in them. I can think of:

 

GoToPoint(), which I know what you're thinking, we already have one of these in LE, but this one would just check that the entity is at it's destination before returning because in a cut-scene you may want to not continue until an entity moved to a position. I feel like we can make "blocking" functions and "async" functions to be used in coroutines for cut-scenes. Async functions do something and return right away, while blocking don't return (still yields of course) until a condition is met.

 

 

GoToPoint() -- this can be used to move the camera around to different pivots that were setup in the scene

GoToPointAsync() -- probably used mostly to move actors around over time (the built-in Follow() and GoToPoint() would be used here as the engine handles updating them every frame

 

PointAt() -- this can be used for cameras to instantly point at other entities

PointAtAsync() -- cameras could use this also to slowly pan over time to a point

 

PlaySound()

PlaySoundAsync()

 

PlayAnimation() -- could really only be used for non looping, 1 time, animations since it would need a finishing point

PlayAnimationAsync() -- would start playing an animation but return right away. we'd need a general animation manager that is being called in some update statement

 

Wait() -- would return after waiting x ms. doesn't really make sense to have an async version of this

 

 

With functions like these I think we could do some pretty cool cut-scenes. I would thinking we could make 1 entity script that takes a parameter that specifies a Lua file that holds a function, and a parameter that has the function name in that file. This function would end up being global but each cut-scene is global to the game anyway so the name of the cut-scenes will need to be unique. Now that I'm typing maybe the name doesn't as we don't play more than 1 cut-scene at a time. Another parameter would be to enable/disable the cut-scene.

 

In the cut-scene entity script we should be able to import the lua file specified as the parameter from the editor. We could create that coroutine using it's function name that was the other parameter in the Start() function. Then when the Enabled input function is raised, it would set a bool that would resume the coroutine each frame in the Update() function. That would call the users lua script which will be calling the coroutine specific functions which have the yield statement in them.

 

I think this just may work smile.png

Link to comment
Share on other sites

This would actually be pretty useful for general gameplay programming, not just cut scenes. This is the type of behavior that is typically provided by custom scripting engines when they are developed for games. For instance, for programming "smart" animations, where the animation automatically generates particles, does damage, plays sounds, etc. during playback, this system would be very useful.

 

If you'd like any help working on this, I'd be interested.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...