Operator — Camera Movement Controller for 3D games

Background

Some time ago I wanted to make a walker game with an ironic story. But I wasn’t going to create level collision objects using cubes in the editor, you know how it is, so … [next sentences are flooded and unreadable] … thanks to @morgerion 's advice I decided to pass the array of dynamic light sources into the shader as the texture … [ink has faded over time] … because it’s great to have full control over the kinematic character and slow it down based on surface tilt … [page ripped out] … ok, but what if I want to make a cutscene like the UT 1999 intro?

Operator

This is a tweakable camera movement controller suitable for 3D games. It can help you smoothly control your character’s camera or make cinematic motion paths using checkpoints.

Showing your player the level by flying around and finish the flight by smooth attachment to the character — sounds like a classic use case.

Play HTML5 demo with flying like :helicopter: and following :blue_car: .

Features

  • Camera rotation and zooming by mouse controls.
  • External manual control by messages.
  • Following an object with avoiding obstacles.
  • Smart alignment to the ground slope.
  • Smooth movement along checkpoints using a bezier path.
  • Switching between multiple cameras.

Local space coordinates and rotations are respected so you can fly between two moving objects without problems.

Bonus

A wonderful bezier module with uniform position calculation comes as the bonus :grinning:.

Documentation

Full documentation is available in the GitHub repository .

27 Likes

Since I’m still not making my own game, I don’t have any real use cases yet. So, if there is anything I haven’t considered, or if something is sorely missing for your case, please write about it.

One of the questions I haven’t been able to answer yet is how to work better with cursor locking using pointer-lock extension by @aglitchman. Right now the behavior is based on the default settings of the extension, but a real game case would need manual control over cursor locking without action binding. I think about cursor locking via messages. But on the other hand, locking the cursor is not the responsibility of the camera controller. So I’m still thinking about it.

8 Likes

This is incredibly awesome!!! Good job!

Would be cool to make an ultra polished version of the demo with production level assets along with cast shadows / ssao / fxaa etc

8 Likes

Exactly! A Defold reel/show-off kind of thing! :open_mouth:

Amazing module @astrochili, thank you for sharing! :heart:

8 Likes

Thank you guys! :blush: The next extension in the ‘Make UT99’ series is coming soon, stay tuned.

9 Likes

Updated to 1.1! :partying_face:

  • The operator no longer attaches to the parent object when following, just following with positions syncing.
  • Removed operator.flight_zoom_easing because the camera zooming is handled by the bezier path now.
  • Refactoring, refactoring…

And I have a few questions that maybe someone can help me to figure out in.

How to animate the camera rotation more smoothly?

Right now it uses the quad in-out easing function by default. It’s also possible to set any custom easing function or some function included in the extension: operator.EASING_INOUT_SINE, operator.EASING_INOUT_CUBIC, etc. But none of them do a perfect rotation animation between motion points, and you can notice this in the demo.

A perfect result can still be achieved by fine-tuning checkpoint rotations and positions, placing more checkpoints in the middle. But it would be nice to do it more automatically.

At first sight, an euler value is the point with x y and z axes those represents angles. Having two euler values, it’s also possible to make a bezier path. But what should be the anchor points in this case?

Have some problems with moving in the collection 3d space in the editor.

At some moment I can’t get closer to the scene in the editor. I created an empty collection, added the same scene there and there the movement is adequate. What can it be?

14 Likes

You should be able to select one of the 3d game objects or models in the outline and then press the " F " key to move the view to an object which matches scale and position of the selected then you should be able to move around and zoom from there with ease. I believe it is a precision issue with zooming in or out from any fixed point and many 3d editing tools have the same problem, moving/centering the view to an object is the solution.

4 Likes

@MasterMind Really works, thanks!

4 Likes

Great job !

2 Likes

That’s a super camera controller, thank you!

There is a small glitch in this version: you renamed the “main” folder into “example” but forgot to change the paths and so get the corresponding error messages:

2 Likes

Thanks for the remark! Fixed in the last commit but without additional release in the hope that releases are used only as extensions links.

3 Likes

This hope is lost on me, I am flying right now through the project I downloaded, couldn’t wait to try it out, so cool!

4 Likes

I’m trying to use Operator as the camera controller for my 3rd-person project, but it’s giving me a lot of trouble/not behaving how I expect it to. For starters, I want the camera to smoothly follow an object (both position and rotation). Is that something that Operator can do?

  1. The documentation on following objects is a bit confusing. Under “Follow Messages”, it says: “The operator can follow the object or follow checkpoints”, but then it starts talking about checkpoints, which I didn’t care about, so then I ended up skipping ahead and searching around and backtracking until I realized that “follow_point” was what I needed, despite it seeming to fall under the “Checkpoints” heading.

  2. The “follow_object_rotation” setting only seems to use the Y rotation of the object, though this doesn’t seem to be documented. Is there a way to make it follow the entire rotation of the object? It seems like the “look” option in the checkpoint properties could do this, but that’s only set once at follow time, it can’t update to the object’s rotation every frame?

  3. Once I had the camera following my “camera target” object, it was horribly jittery when I rotated the camera that the target was attached to. I’m not sure what it’s doing, possibly due to some frame lag?

  1. I expected the “smoothness” setting to affect following, but I guess that’s only for input? Is there a way to have the camera smoothly follow an object? I tried using the “speed” setting for the follow point, but that only seemed to affect how long it took to get there initially, not how fast it continued to follow if the object moved. Also, that feature broke if I rotated the parent of the target object while the camera was still animating towards it. Then the camera would be permanently offset:


The end result that I’m looking for is: A camera that follows the location and rotation of an object attached to my player, possibly with some smoothing. The option for this camera to smoothly fly away from the character to follow a different target object (to match it’s location and rotation—which would possibly be in motion), and then fly back.

But I will also possibly use the bezier curve following, which is why I thought I’d use Operator instead of just doing the following myself.


[Edit:] :thinking: On second thoughts, it will probably be easier for me to write up the simple following code that I need right now rather than try to force Operator into doing something it’s not meant for, but maybe this review/report will be useful to you anyway.

4 Likes

Where to start… Thanks for such a detailed review of the problems you’ve encountered, as your experience is probably the first, or at least the first to stimulate to write this.

I made the extension primarily for the first-person character controller, and made the rest as additonal features to publish not a “just a first-person controller”. Maybe that was a mistake, since I didn’t end up using it for anything.

I’m looking at the documentation now and I don’t understand much myself without diving in. Definitely your comments make sense. I have moved the “Checkpoint” section.

There are no special restrictions in code. I need to dive into the issue, I’ve never tried following objects that have a different rotation than the first / third person character.

The look property of the checkpoint is simply the direction of the look when using the lua table, instead of setting the rotation for checkpoint.go directly in the collection.

I don’t know exactly, hard to say without an example project. Since this camera is most fine-tuned with Kinematic Walker, I think it makes sense to look at the example integration and just try on whatever is there on your character.

Yes, that’s the smoothness of the input. Smooth following with soft lag and catch-up were not implemented in this library, although it’s the most expected part of it.

Someday, if I do get into 3D game development, I’ll revisit that functionality. For now, it can be added by the invisible proxy object that follows the character smoothly and operator following this object.

Post Scriptum

I’m sorry that a library that positioned itself as a camera operator has, after two years, failed to live up to its promises. Two years ago I would definitely have been very quick to fix or add anything on the same day, now the circumstances are a bit more complicated.

I was naive enough to hope that this was necessary in 3D development on Defold, because it requires users and feedback to polish bugs and functionality. But there was almost none, because the level of 3D game development on Defold reqires experience, and experience often motivates the implementation of your own solutions.

So, it turns out, I can say that it works well in the use cases that are present in the demos of operator and walker. In any other case, sort of yes, but all the nuances of multifaceted usage are likely not accounted for and will require debugging and adjustments.

6 Likes

You have nothing to apologise for! Like you said, the situation was completely different for Defold two years ago. A lot has happened and now we have a lot of new features and users willing to test them!

4 Likes

I also don’t think you have anything to apologise for! The extension is amazing and for what it serves for it’s great. You pushed the boundaries of 3D in Defold back then, it was already an achievement :heart:

2 Likes

The assets are fantastic :slight_smile: Pinching a quote from another thread ‘we need to understand the fundamentals’. It is not practicable for an asset to ‘just work’. To attempt (and not succeed) to do this, the asset would need to be an entire game engine that would sit on top of Defold, the user would then not touch Defold at all. It is good to not obfuscate technicalities away. So-long and thanks for all the assets:-)

2 Likes

It seems I’m a bit late for the feel-good train. :laughing:

I wouldn’t say it failed to live up to its promises, just maybe the promises/expectations were a bit too vague to begin with. It’s easy to read “This is a tweakable camera movement controller suitable for 3D games.” and optimistically think it will handle any sort of 3D camera setup. I’ve seen it used in plenty of projects as it was intended along with your Kinematic Walker.

Thanks for taking a look. The modifications to the readme make it much clearer I’d say. :+1: If I find the time I may try to debug the jittering I found (and maybe other things) and submit a more detailed report or PR.

I actually think that smaller, more modular libraries would be more useful. “Just a first-person controller” could see a lot of use! To me it was odd to find that the Kinematic Walker didn’t handle rotation controls at all, that that was handled by Operator. I don’t think that every asset needs to be a Library either—general-purpose single scripts or modules that are easy to drop in and use are nice too.


[Edit:] :thinking: To be most useful to me, these two libraries (Operator and Kinematic Walker) would be broken up into a few smaller pieces that were self-contained, easy to drop into any project, and easy to modify (ideally):

  1. A kinematic collision handler (probably as a lua module of functions)
  2. An FPS character controller: walking, looking with the mouse, possibly jump, run, and crouch as well. I would probably include options for looking with gamepad or keys and Y-axis-limited looking, since some people are into those things.
  3. A “spring-loaded” 3rd-person camera arm with collision checking (like Operator already has…I think).
  4. A ‘following’ script/set of scripts with smooth following and bezier paths.
2 Likes

Oh, guys, thanks. I melted :grinning_face_with_smiling_eyes:

Agreed. Your list of modules 1-2-3-4 is really optimal, I like it. This is a good way to divide the functionality according to the real needs of developers.

5 Likes

I totally agree! Libraries are for the larger and more complex things. You can absolutely have a repository with a bunch of single file modules that you can pick and chose from. Similar to https://github.com/nothings/stb

3 Likes