Can I run the project by code?

Godot Version



I am making a custom tool for my game. It should load and run an Animation resource when pressing a custom button in the editor.


The “preview cinematic” button should run a scene

It should help me debug cinematics and interact with other plugins. I need this because I can’t preview all the camera switching, animations and dialogue in the editor and triggering the cinematic in game every time is very time consuming.

The problem is that I can’t find anything about running a scene (or the project) through code (as if I pressed F6) Can I run the project by code?

This is my first post here and It’s almost out of desperation because I can’t find any information about this anywhere.

Thank you very much in advance.

An animation resource isnt a scene, but the rest of your ask sounds like you want get_tree().change_scene_to_file("waking_up.tscn") This is very similar to F6.

Playing an animation dynamically will be difficult given how many paths need to line up for it to work.

var library = animation_player.get_animation_library("")
library.add_animation("preview", waking_up)

Thanks for your reply!

Unfortunately, that doesn’t solve my problem.
When I run this code in the editor, it doesn’t open a new window like running the game does but tries to change the editor window into that scene im trying to run.
The game isn’t running yet, I need to run it and load that specific scene.
The plugin Dialogic makes something similar to what I’m looking for by loading a preview scene and running the game (I have tried to look at how they do it but I must be blind because I can’t see it)

My idea of how I would like it to work is:
Press custom tool button in editor → Game Runs → Scene Loads → Animation plays

To start a scene from a tool script use


I believe dialogic has some sample scenes they insert the timeline into.

1 Like

Thank you! This was it! I was blind indeed :sweat_smile: