Skip to content

u/AlexSand_

In this archive from Sep 2023 to Nov 2025

48
posts
47
comments
15
media
2.9k
score
3 saved before deletion

As a side note, it is perfectly possible to use Godot * without using the editor * ; but as a kind of framework, by instanciating every node from the code. That's even my prefered way of working with Godot.

Compared to other frameworks I had tested, I would say it is very complete (no need to find an external library for the ui...), has a great and dynamic community (which believe I'm weird when I tell I don't use the UI, but I got used to it :) ), and for these times when I feel like defining some scene in the editor it's just there.

1 points

so I found again my own unanswered post a few days ago, while investigating another instance of the same bug.

But now I found at least a partial answer, and I can answer myself, so if I google this again one year from now I will have some leads ;)

  • This seems to be a threading issue, which would happen when a calling "connect" from another thread.
  • the biggest 'problem' typically happens queuefreeing the connected node / the node it conected too: connections data are in a wrong state and the engine loops forever trying to disconnect.
  • More information here: https://github.com/godotengine/godot/issues/60098
  • I think the infinite loop is happening here (in 3.5, but seems to be still there in latest versions...), that would happen when freeing the node connected to: https://github.com/godotengine/godot/blob/3.5/core/object.cpp#L1984
  • Finally, this bug might happen by calling some engine primitives which call "connect" behing the hood. I'm pretty sure it was the issue I encountered, with the AnimationPlayer calling connect.

So if you read this page because you had a similar problem, I wish you good luck ;) (and I'm puting back most node instanciations in the main thread; with a queue to process these by small chunks to avoid lags)

1 points

well of course!

I basically started to get serious about working on my own game after getting frustrated by a few things on a "similar" game I had played 100s of hours :)

(example: some turn based battle which were sometimes too long. This motivated me to implemented a "switch to Real Time" button in my own prototype. )

And I also installed and played a few other similar games to get inspiration. I did not go as far as reading reviews,but it seems actually a quite good idea.

And I'm doing that as "mostly a hobbyist", even if I finally took some time off from my main job to finish the game. I would expect that more "pro" devs seriously study the competition.

4 points

As everyone said, you start with something simpler. Ideally this "simpler" thing should be a part of your final game, so you're already working on your 'big' game.

Other redditors suggested to start with the networking, because it is likely the hardest part. I would suggest otherwise. Networking might be just too hard for you now, especially if you're not proficient in coding. It also makes it more awkward to test, and more difficult to have something to show.

Instead, start with a single player run, with a single room, and a single enemy. From there, update things one at a time (one more enemy, a different dungeon map, ...) until it's something playable.

... And I'd lie if I said that you be will able to fully reuse this part in the final project: I don't have xp with working on multiplayer games myself, but it's quite clear it requires to take this constraint early in the architecture. However, if you get there you will have learned how to make it, and will be able to reuse some parts, and will be in a better position to restart the project with a multiplayer setting.

2 points

this depends a lot where you're starting from. Personally, I'm more or less working professionally as a dev (well actually researcher, but with a strong coding background), from my point of view coding is not the hard part in game dev. Coding is technical, you certainly have to work to learn it, but once you know what you are doing it's not the difficult part.

If you ask me, the hardest part is the design, ie knowing exactly what I should code. Not the overall idea, but the *tiny, ugly details which makes or break a game*.

Things like " I want a 0.2s delay between a hit and applying the damages", else the anim may look totally weird. Or balancing "how many xp I should award the player as a function of the enemies he defeated" Or "how should I show the player that the selected unit just changed because it has no more action points" ... those details may seem trivial from far away, but the amount of such tiny details is really the difficult part to handle well.

34 points

Thanks! I landed here after googling, and this solved my issue as well.

( I had a somewhat similar error after checking how bad it is to migrate to godot4. - conclusion: not gonna do it- . Resetting my project with git did not erase the .import file, and the font import were likely messed up by godot4.)

1 points

I have never written a spatial shader, and I'm not even sure what you are trying to do, but here are a few things which come to my mind in this code :

  1. 400 samples seems a lot !

  2. color += textureLod(mask, UV + scale * vec2(float(i)), spread).r * weight;
    You are just summing the scalar .r channel ? If, maybe make a scalar sum, to replace the 400 vector additions by scalars computations.

  3. color = color / total_weight; This is called twice, meaning that sampled collected on the first pass get divided twice by total_weight. That looks buggy, is this really intended?

  4. if I am correct in 3) you can replace the two loops by a single once for better readability

  5. speaking of the two loops, you are collecting on two axis starting from current points, but not samples around the point, which would require two*nested loops. Did you really want samples on the axis only? ( but if course , the nested loops may be prohibitively costly)

  6. still to reduce the cost of computation: float width = 1.0 / sqrt(PI*2.0 * SAMPLES);

this line is correct, but can actually be removed. Indeed, since you are making a weighted average (once again, I assume 3) was a bug on your side) , you do not need the distribution to be normalized.

  1. I suspect you are using some samples which are just too far from the initial point to have a significant weight. eg when i = 100, then x_squared /(2.0 * SAMPLES) is 25, and exp(-25) is already really small.

float x_squared = x*x;

float width = 1.0 / sqrt(PI\*2.0 \* SAMPLES);


return width \* exp((x\_squared / (2.0 \* SAMPLES)) \* -1.0);

You may want indeed a standard deviation (the "width " ) directly proportional to SAMPLES, so that the furthest samples is always at say at 2 or 3 standard deviations from the origin. Then there are likely some better numerical methods (some kind of importance weighting) which would be more sample efficient, but avoiding sampling things with a near 0 weight should be a good start.

I feel somewhat sorry for this long post, but I hope it may help :)

1 points

Note that you may also choose to totally skip the editor. Godot node subclasses can be used just as if it was any library.

In the code:

class MyCustomNode:Node2D // or whatever Godot node you need
{
    public MyCustomNode(MyParam param) :base()
    {
    }
    ... // your code, as in any regular class
}
...
var mynode = new MyCustomNode(param);  // instanciate as any c# class
parent.AddChild( mynode); 

and *nothing* in the editor.

Personally, I ended not using the editor *at all* except for defining animations. (Not saying it is better, just that Godot can also work nicely this way.)

1 points

As a side note: there might be a design flaw in having items with both a state (like "how much water") and a count. Basically you have three options: either "stackable" items with a count but no state, or "uniq" items with a state but no "count", or some big heachache later when you try to get both working :)

I'm not saying this last option is not possible, just that it is bug-prone. (Like, what exactly should happen when you add an "empty" can to a stack of "full" cans? )

1 points

and here is my own version: ( Not strictly a godot Timer, because I wanted it to follow changes in game speed, but I do not believe it makes a large difference)

public static void RunDelayed(this Node node, Action action, float delay)
{
    var timer = new MyTimer(action, delay);
    node.AddChild(timer);
}

public class MyTimer : Node
{
    Action _callback;
    float _remainingTime;
    bool _applyGameSpeed ;

    public MyTimer(Action callback, 
                   float timeDelayInSeconds, 
                   bool applyGameSpeed = true)
    {
        Name = "MyTimer";
        _callback = callback;
        _remainingTime = timeDelayInSeconds;
        _applyGameSpeed = applyGameSpeed;
    }
    public override void _PhysicsProcess(float delta)
    {
        if (_applyGameSpeed)
        {
            delta *= GameSpeedHelper.GameSpeedFactor(); // this is my own code base, adapt as you wish
        }
        _remainingTime -= delta;
        if (_remainingTime < 0)
        {
            _callback();
           this.QueueFree();
        }
    }
}
2 points

It depends what you are doing of course :)

But as a rule of thumb: threads are dangerous, yes. Even something as harmless-looking as a good old c# "Random" object can bite you hard if you are not careful with threads (true story :) )

And I think that Godot is "mostly" thread safe (which for my parts reads as "don't use threads if you don't have too") https://docs.godotengine.org/en/stable/tutorials/performance/using_multiple_threads.html

1 points

I would not feel comfortable using threads if I don't have to. Personally I just have a helper function wrapping a godot timer to add it in one line. One advantage of the timer solution as a child of current node is that if current node is freed, timer is cancelled and nothing bad happens. (And if I don't want this behaviour, I add the timer as child as something else). Now this may not be optimal performance wise, maybe the method proposed here would be better from this point of view.

1 points
...  but it's always worth taking a second look when you think about using these functions, and asking "is this the correct way to approach the problem?"

Well, I can't agree with that. Better safe than sorry, and having a game which does not crash is priority number 1.

I use it even is I am 100% sure that my instance cannot be invalid, because i don't know how my code will be refactored later. ( and after that ... yeah think about why it would be invalid, log some error if need be and so on. )

And about freeing early or not ... I believes this is a coding style choice. ( I usually have "logical" objects which are not nodes and thus never queuefreed, and "viewer" of these logical objects which are nodes and freed as soon as there are not displayed any more. )

1 points

yes ... expect that if instance is a deleted node, this will crash, because the "?" does not detect invalid nodes, only nulls. You may look at the extension method "IfValid()" I proposed in the first post to see how I use this ? operator. (And I agree with you about that, this operator is an ultra nice c# feature )

1 points

Good point. To be fair, the main reason I had kept node != null in my code was so that I do not wonder "oh, but what happens if it null?" every time I look at this part of the code.

I believe the perf impact is epsilon, and smaller than the benefit for my own sanity :)

2 points

as the other poster said, it does not crash because it is an extension method, not a method from the object. It is perfectly equivalent to do

if( MyStaticClass.IsValid(_myNode ))   ...

However, where you get a point is that this fact above is non-obvious for people unfamiliar with c#, and ... yes, the whole post could be summarize as "check that the object is (non null and valid), not only that it is not-null"

2 points

lets say your "player" node keeps track an a "_target" node the player is attacking, and sends a rocket in the direction of "_target.Position" every 10 frames. And that the _target gets killed, (by the rocket or whatever) and removed from the scene with queue_free. Then is you are not careful, the code will crash next time you try to get "_target.Position" because _target was freed.

2 points

It doesn't need to be freed in the middle of executing something. You might have saved the node to a variable long ago already for whatever use.

No, does not crash when the ref is null. The trick is that IsValid is not a method of "_myNode" , but an "extension method". Extension methods are just a different syntax for calling a static method, actually the call is exactly equivalent to " if( MyStaticClass.IsValid (_myNode ) ) " ( Where MyStaticClass is where IsValid was defined)

3 points

Thanks for the heads up. You have any other helper/utility/extension functions you use a lot? Just started using godot this month after a lot of Unity (7 years) so I'm slowly getting used to the engine but don't know a lot of the shortcuts and pitfalls yet.

Likely, but none so useful. and I have to do a bit of cleaning before I post :)

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.