0 votes

Hello,

So I've been working/trying/learning godot for a week now and i noticed that it lacks "actions" (for example fade out action. Set a timer, and over that timer the fadeout action would be performed). I've tried replacing it by using fixedprocess or _process to simulate timers by using delta, but that's not really clean. Also used the Timer node, but having multiple of those auto cleaning becomes tricky and it isn't a clean way to do it either.

So I got an idea to make some specific class that would have actions to work on and auto clean after. I have experience writing this kind of thing so writing it is no problem to me. My problem is:

  1. Is there a smart way to include other script files?

  2. Is there a way to make script files part of the core? (Kind of like everything else godot offers) Or do i have to work on the cpp side and recompile the entire engine?

  3. How does load and preload work - exactly. I know load loads when you ask it to, and preload loads before the _ready() is called. But i'm curious when the preload starts? if i have a node that isn't yet added and it has a script that preloads, does the preload only happen when i add the node? If i have multiple nodes that preload the same file, does the same file preload multiple times? How stupid would it be to just use preload for some core helper functions? (Like actions i mentioned)

in Engine by (12 points)

This isn't an answer to your question, so I'll just add it as a comment. In order to fade out something you can simply use an animation.
If you must do it in code you can use the Tween node to accomplish the same thing. See here: http://docs.godotengine.org/en/stable/classes/class_tween.html?highlight=Tween#class-tween-interpolate-property
In the description ( http://docs.godotengine.org/en/stable/classes/class_tween.html?highlight=Tween#description) there's even an example that uses the method you are probably most interested in.

1 Answer

+1 vote

1- Don't know what "smart way" means.
2- You can add your own module if want something extra as part of the core and compile the engine with it (c++). There's the option of plugins/tools if you want to make a custom node (not part of the engine).
3- Preload happens at parse time as doc says https://godot.readthedocs.io/en/latest/tutorials/step_by_step/scripting_continued.html#instancing-scenes

You can make those "actions" with animations, example:
- create an opacity animation that affects the parent.
- save it on disk as resource.
- load it on the animationplayer of every node you need that animation on parent _ready.
- play it when needed.

by (7,860 points)

Yeah, I wouldn't want to be using it the dumb way. XD

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.