-
-
Notifications
You must be signed in to change notification settings - Fork 20.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Game camera override #27742
Game camera override #27742
Conversation
50e77b7
to
474d1de
Compare
This looks great! I was just about to open an issue requesting this feature 🙂 |
Nice, It would be grate to have the game run inside the editor as well (for tweaking values when using sync scene and script changes) if you have a single monitor. |
@OBKF this is already possible. 🙂 When you launch a game, you can make changes to your script while it's running and when you save the script, it is hot-reloaded in a running game. Also changes that you make to values in the inspector are instantly replicated in game. |
If possible, I think a button in the toolbar would be better. Else the feature looks cool, nice job. :) |
@groud I tend to agree that the less clutter in the viewport the better. However, since you can have multiple active viewports in the 3D view, I thought placing the button in each viewport makes more sense, rather than having a button in the menu where user would have to pick a viewport by an ID or something similar. Anyway, the UI is still in kind of a prototype state. Maybe to solve the "issue" with multiple 3D viewports, there will be a single button in the toolbar and it will simply replicate the viewport that was used the last. Or each time the user interacts with a different viewport, the replication switches to it. This could be a bit trippy, though. |
@SeleckyErik I was referring the other way lol. |
@OBKF I think it was a deliberate design decision to not have a game running inside of the editor. |
@SeleckyErik I think at first, but then the stance changed. I know it has been attempted at least twice, but never got far enough to actually be tested. |
Hmm... I didn't know that. Indeed it would be an interesting feature to have. |
Most of the times the game runs differently from the editor, for example there is no |
I think the PR is mostly good, but I think the way to override the camera is not so good. This is not your fault, but the fact there is not a clean way to do this. Let me see if I can add relevant functions to Viewport for this, to make your life easier |
If you can give me some pointers on what is not so well done and what would be your proposed solution, I can attempt implementing it myself. I can only imagine you have more than enough tasks on your to-do list. |
@reduz any update on this? Will you have time to work on this any time soon or explain me what needs to be changed? I will be working on the watches now, but afterwards I want to get back to this PR. |
fb3c8ee
to
74d8ab9
Compare
Squashed all commits |
Noted. Will make the changes and get back to you. :) |
I believe I addressed all the issues that you pointed out @reduz. The only thing I am not sure about is whether the Also, I'd say that when the camera override is used, the overriding camera should be used for the spatial sound, rather than the in-game camera. However, since the |
e95f8e0
to
1db536c
Compare
6f27dec
to
0531b31
Compare
a152824
to
a2b5fc9
Compare
6ff63be
to
83f08c9
Compare
Summary of what was discussed at the Godot Sprint:
|
83f08c9
to
e9a7694
Compare
Implemented uniform API in Viewport class to override 2D and/or 3D camera. Added buttons in 2D and 3D editor viewport toolbars that override the running game camera transform with the editor viewport camera transform. Implemented via remote debugger protocol and camera override API. Removed LiveEditFuncs function pointers from ScriptDebugger class. Since the debugger got access to the SceneTree instance (if one exists), there is no need to store the function pointers. The live edit functions in SceneTree are used directly instead. Also removed the static version of live edit functions in SceneTree for the same reason. This reduced the SceneTree -> Debugger coupling too since the function pointers don't need to be set from SceneTree anymore. Moved script_debugger_remote.h/cpp from 'core/' to 'scene/debugger/'. This is because the remote debugger is now using SceneTree directly and 'core/' classes should not depend on 'scene/' classes.
e9a7694
to
8b0546d
Compare
// This is for the camera override to stay live even when the game is paused from the editor | ||
loop_time_sec = (OS::get_singleton()->get_ticks_usec() - loop_begin_usec) / 1000000.0f; | ||
VisualServer::get_singleton()->sync(); | ||
if (VisualServer::get_singleton()->has_changed()) { | ||
VisualServer::get_singleton()->draw(true, loop_time_sec * Engine::get_singleton()->get_time_scale()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made camera override work even when the game is paused from the editor.
@rxlecky What do you think about an icon like the one below? It's based on the CameraTexture icon, but with a larger camera icon and a thinner rectangle (1 pixel instead of 2 pixels). Optimized SVG: icon_camera_sync.zip |
@Calinou I'm not sure if that quite gets the idea across. I was thinking of something illustrating two cameras being linked together. But that seems like a difficult thing to fit in an icon. Maybe something simpler like a combination of camera icon and a panning tool would do? Not quite like this but you get the idea 😄 |
It's now a bit late for 3.2 given the release freeze, but as this was reviewed extensively over the past few months by @reduz and we approved it at the Godot Sprint, let's make an exception. |
Thanks! |
I assume this text is out of date, because this PR changes |
@aaronfranke Indeed, it works well in 3D from my testing. However, I noticed that camera FOV is only set if you set it while the preview is enabled. If you disable camera replication, change the camera FOV in the View settings and enable it again, it won't use the new FOV value (#33847). |
The mentioned disadvantage of godot is now obsolete since godotengine/godot#27742 was merged for 2D and 3D, and the game camera can be overridden from the editor to explore from multiple angles.
The mentioned disadvantage of godot is now obsolete since godotengine/godot#27742 was merged for 2D and 3D, and the game camera can be overridden from the editor to explore from multiple angles.
Suggested improvement to this feature from godotengine/godot-proposals#1864 (comment)
|
Added a button to the 2D and 3D editor viewports that toggles replication of the viewport camera into running game.
So far, only 2D camera replication works. 3D is WIP.