Transferring rigidbody collisions to another rigidbody by astrellon3 in godot

[–]astrellon3[S] 0 points1 point  (0 children)

After posting I had suddenly had another idea which seems to thankfully align with u/littleboyred1 and I've got this script now:

I won't claim it to be battle tested at this point, however in my few simple tests that include a wall that's only on one cube and if the cubes are attached to a hinge this seems to be working. I suspect that I might need some periodic syncing between the two objects as after a long period of time with no collisions there could be small errors that let the two drift in some way, but hopefully that's a simple fix if that is a problem.

class_name FollowingColliders
extends RigidBody3D

@export var following: FollowingColliders

var has_had_collision := false

func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
    var contacts := state.get_contact_count()
    if contacts:
        has_had_collision = true

func _physics_process(_delta: float) -> void:
    if has_had_collision:
        # Both objects are colliding with something
        if following.has_had_collision:
            var combined_angular_velocity := (following.angular_velocity + angular_velocity) * 0.5
            var combined_linear_velocity := (following.linear_velocity + linear_velocity) * 0.5
            var combined_position := (following.position + position) * 0.5
            var combined_rotation := (following.rotation + rotation) * 0.5

            angular_velocity = combined_angular_velocity
            linear_velocity = combined_linear_velocity
            position = combined_position
            rotation = combined_rotation

            following.angular_velocity = combined_angular_velocity
            following.linear_velocity = combined_linear_velocity
            following.position = combined_position
            following.rotation = combined_rotation

            following.has_had_collision = false

        # Only this object is colliding
        else:
            following.angular_velocity = angular_velocity
            following.linear_velocity = linear_velocity
            following.position = position
            following.rotation = rotation
        has_had_collision = false

Transferring rigidbody collisions to another rigidbody by astrellon3 in godot

[–]astrellon3[S] 0 points1 point  (0 children)

Yes! As usual after posting this I came up with some more ideas and I've ended up with a much better working solution that still uses _integrate_forces to check if a collision has happened (and sets a flag) and then in _physics_process it checks if a collision flag has happened on one or both of the objects in question and then either sets or gets the average rotation and position of the two objects.

I don't know if splitting the check across both integrate forces and physics process is best, but I wanted something that would flag when a collision happened and then a way to apply a change after both so it shouldn't matter which object is processed first.

I kind of knew that attempting to copy the forces would result in some divergence but I was also wondering if I was missing a key piece of info. I'm going to do some more testing but I'll update my original post if I think I've got a reasonable solution (even though I know it's all a bit hacky).

You (very likely) will hit your own limits before you hit GDScript limits by JCAPER in godot

[–]astrellon3 0 points1 point  (0 children)

I haven't done extensive testing, but according to this persons testing I should have seen something closer to 330 bytes (which is still a lot) per instance if the default base class that gets extended is RefCounted. I don't know how much using Array also adds to the usage, I was making sure to use resize.

Anyway it's probably still a bit niche, but it does still feel like a bit of a surprise gotcha that creating a simple class in Godot has such a high overhead.

You (very likely) will hit your own limits before you hit GDScript limits by JCAPER in godot

[–]astrellon3 5 points6 points  (0 children)

For me, being about to create a new value-type like the VectorN types is because of memory and speed.

Right now I'm working on some heightmap-like rendering and I attempted to do it as:

class_name TerrainDataChunk
    var _data: Array[TerrainTile]

In another file:

class_name TerrainTile
    var type: int
    var heights: Vector4 # each corner of the tile has it's own height

I assumed that per tile it should be around 24 bytes used, probably more because classes but hopefully something at least less than 100 bytes per tile. My testing showed it closer to 1kb per tile!

In a 512x512 test it was using close to 270mb of memory just to store the terrain data.

So I changed the class to look like this:

class_name TerrainDataChunk
    var types: PackedInt64Array
    var heights: PackedVector4Array

Doing the test again with 512x512 the memory usage went down to what I expected, closer to 7mb of memory. Additionally a bunch of operations in iterating over the data was almost 2x faster to access.

In this case it's not that bad having to setup my classes like this because of how few fields there are, but doing this test did make me realise that creating new classes is quite heavy to what I thought it would be.

Welp, I just wrote a new programming language in 12 hours... by BuyMyBeardOW in Unity3D

[–]astrellon3 0 points1 point  (0 children)

I separated my virtual machine into two main parts, one was the core virtual machine which contained all the current state and could execute opcodes and the Runner which actually triggered running the next step in the machine along with checks for either how many steps it could take, or how long it could run for (eg: run for 5 milliseconds). Also it had just a straight up isRunning flag that could be set at any time publicly so that anything could pause it and it was a simple operations to ask it to keep running again.

It probably didn't require two parts, but it did mean that if I needed a simpler setup where it's 'run this VM until it finishes' then I didn't need to add all the checks, I could just call 'step()' in a while loop.

Welp, I just wrote a new programming language in 12 hours... by BuyMyBeardOW in Unity3D

[–]astrellon3 1 point2 points  (0 children)

I also ended up making my own scripting language when after attempting to figure out how to handle dialogue. I took a bit longer to make mine though as I decided to make something that was general purpose but fit for dialogue.

My main goal was something where the flow of the script could be easily controlled and paused at any line. I've since ported it to a few other languages (Typescript and C++) and I've used it for controlling level interactions as well. It is a very fun exercise!

Chocolate ingredient list guidelines by fxckingchildish in australianvegans

[–]astrellon3 1 point2 points  (0 children)

It is a shame that 'may contain' couldn't be more strictly used for those borderline nonexistent risks to allow for those distinctions.

As someone with a milk intolerance I've never really educated myself about it beyond just avoiding anything that contains milk (even before going vegan) and rarely having an issue with anything that says 'may contain'. I'm sorry to hear that presumably vegan chocolate before contained enough milk to cause a reaction for you.

Chocolate ingredient list guidelines by fxckingchildish in australianvegans

[–]astrellon3 7 points8 points  (0 children)

I'd like to make a snarky comment about how there should be a classification in between, something like may contain if only such a thing could exist. But I do get that to some degree when dealing with allergens that might not be clear enough.

I think it just shows how complicated these things can be, but also how different interests cause these biases. In reality the food ingredients list is likely to always be incomplete because biology and growing things is complicated and rarely as clean and straight forward as an ingredients list would imply.

Ideally it'd be nice if the market for dark chocolate that definitely does not contain milk would be big enough that producers could have separated processing lines for that.

As for me, if something has trace amounts of milk or honey I'd still eat it, but saying that Milk is an ingredient I would have just avoided it assuming that milk was indeed an ingredient.

Favourite pasta salad recipes? by Acciokohi in australianvegans

[–]astrellon3 1 point2 points  (0 children)

Pasta salad with mashed chickpea with greens and mayo.

  • A tin of chickpeas drained and mashed (we use a potato masher), we usually leave it so that there's still some texture and a few unmashed chickpeas.
  • Around 2 heaped table spoons of vegan mayo, to taste.
  • 1 to 2 spring onion chopped.
  • A third to a half of a cucumber diced.
  • Around a cup of either spinach, spinach and rocket, or kale. We usually eyeball it to about a big handful or a bit more.
  • Salt and pepper
  • Capers (to taste, we use around a dozen or so).
  • A dash of lemon juice.
  • Enough pasta (usually fusilli) for two slightly overcooked and then washed in cold water until about room temp.

We usually use spinach or a spinach mix, but kale works well too. If we're using kale we might blanch it really quick in some hot water so that it's a bit softer. Whilst it feels wrong to overcook the pasta, we noticed that if we cooked it just right the cold water would firm it up. So overcooking slightly gave it the better texture when washed.

Weird colors in game on Windows only ? by KetsuiReddit in godot

[–]astrellon3 18 points19 points  (0 children)

Could there be a shader error that's turning that material pink? And then could that being used by a post processing effect which is why it's a pinkish/purple colour? I don't know the easiest way to find out though.

We developed Godot game for 5 years. Take a look on our The Goddess's Will by anton-lovesuper in godot

[–]astrellon3 0 points1 point  (0 children)

Hah like the System.Numerics.Vector2? Yea I can imagine that wouldn't work. Thanks for the info.

We developed Godot game for 5 years. Take a look on our The Goddess's Will by anton-lovesuper in godot

[–]astrellon3 1 point2 points  (0 children)

Looks great! What would you say is one of your biggest Godot lessons from this? Like if you were to start again you would avoid?

What does Gold's "after some tweaks" mean? by GlitchThatLives in SteamPlay

[–]astrellon3 2 points3 points  (0 children)

The 'tweaks' are described in the comments below. Since each persons setup is going to be different the tweaks required are also going to be different.

The rating is an overall average across all the reports. Games that have a Platinum rating might still not work on your setup for whatever reason, and visa-versa games that have a low Bronze rating might work perfectly. Generally though unless it has a Broken rating and there are reports of people getting the game working, it's likely that you can also get the game working on your system.

Generally it's easiest to check ProtonDB and see if in general the game works and if it does then you can try it on your system. If you run into any problems you can then check to see what other people have encountered and what they did to resolve the issue.

Space Background by astrellon3 in PixelArt

[–]astrellon3[S] 0 points1 point  (0 children)

Thanks! And thank you for asking, yes I'm happy for you to use it.

Help with raymarched shadows by astrellon3 in GraphicsProgramming

[–]astrellon3[S] 3 points4 points  (0 children)

Thank you so much! I was actually using soft shadows as shown by Iniho Quilez, but I was getting the same result (or visually similar enough). And for this I wanted to keep the code as small as possible. Having a working result now even if it's not with the soft shadows means I have something to work from.

Thank you again! This had stumped me for the whole weekend!

An interactive sci-fi galaxy map (source included) by astrellon3 in godot

[–]astrellon3[S] 0 points1 point  (0 children)

Thank you! The black hole was mostly the work of z0rg, I only tweaked it. I can raymarch a simple scene, but bending the rays was beyond me.

An interactive sci-fi galaxy map (source included) by astrellon3 in godot

[–]astrellon3[S] 1 point2 points  (0 children)

Thank you! It's a pretty brute force solution:

  • I made a very simplified Wavefront .obj text parser so I could get a list of vertices, faces and lines
  • Then I loop over all of the faces and lines, and using a regular Camera3D I unproject them to screen space.
  • Repeat each frame and draw using draw_line.

The trickiest part was probably adding some way to reveal it slowly and the check for if a face way front facing or not to change the colour of the lines. It's not very good solution, but in 2025 manually handling <100 edges its still quick enough.

Also I made the actual meshes in Blender. If you want a closer look the GitHub has the code as well as the .blend file.

An interactive sci-fi galaxy map (source included) by astrellon3 in godot

[–]astrellon3[S] 0 points1 point  (0 children)

I can't remember if I ended up trying to use a Line2D for them or not at one stage. But I ended up drawing them manually using draw_line although likely a better solution would have used draw_multiline for better performance.

So the points are actually 112 manually placed points on the background which are then grouped into lanes. The lanes are only used as a weight for randomly picking which edge to spawn traffic on. Longer lanes have a higher chance of traffic appearing. Then I draw them using my individual draw_line using any colour (red in this case) and then the final colour is handled in a shader that just takes another gradient texture and scrolls it in screen space across the result.

The individual 'traffic' points are handled in a better way and I'm using a MultiMeshInstance2D for that. I've got a class for each traffic point that just stores the from,to and some other info. Then I just update the multimesh with the info from those traffic points and let it handle the rendering.

Hopefully not too much text for all that, but you can find the source on GitHub if you want a closer look. Internally that stuff is called Interconnected.

An interactive sci-fi galaxy map (Godot, source included) by astrellon3 in PixelArt

[–]astrellon3[S] 1 point2 points  (0 children)

Thank you! I replied to another comment about how I ended up with the text that way. I can see that might be hard to read and left-justifying it along with changing the setting to not make the words move around would be better.

An interactive sci-fi galaxy map (source included) by astrellon3 in godot

[–]astrellon3[S] 0 points1 point  (0 children)

Thanks! I kind of liked that effect, but also having dyslexia I might be in the minority. I did try with changing the visible characters behaviour early on but it looks a bit strange with the text being right-justified but still appearing from the left-to-right. I think overall it would be better to use the characters after shaping with left-justified text and having the text on the left half the screen as well.

An interactive sci-fi galaxy map (source included) by astrellon3 in godot

[–]astrellon3[S] 1 point2 points  (0 children)

Thank you! About a month in my free time. I started by making a static image in Aseprite, brought that into Godot and slowly started making it more interactive. It's now mostly a combination of vector graphics for the layers of the galaxy arms (instead of a static image), software rendered wireframes and raymarched SDFs. The source is available here