Search

Help. Need help with adding Area2D to groups dynamically


I have instances of this area2d object that spawns and is added to a group dynamically. when they collide I want them to say their name and the group they are in. right now they report their name but not their group and I can't figure out why, when they instantiate they report the group they are in so it looks like they're in their group but when they collide the group is missing.
var type_groups = [ "pluto", "moon", "mercury", "mars", "venus", "earth", "neptune", "uranus", "saturn", "jupiter", "sun" ]
func set_type(t): type = t
undefined
# Adjust for paths or hierarchy var shape = get_node_or_null("CollisionShape2D") if shape: shape.scale = Vector2(type_sizes[t] * 5.5, type_sizes[t] * 5.5) var detect = get_node_or_null("Area2D/CollisionDetection") if detect: detect.scale = Vector2(type_sizes[t] * 5.7, type_sizes[t] * 5.7) detect.add_to_group(type_groups[t]) print("added to group: ", type_groups[t]) var sprite = get_node_or_null("Sprite2D") if sprite: sprite

How to apply a shader to a sprite without it becoming a rectangle?


I have been looking for a 2D reflective water shader for some time and was delighted to see that this tutorial was posted on YouTube to create just that:
https://www.youtube.com/watch?v=wPr5PvSgxFo
I've had a go at implementing it and have got the reflective water rendering. It's very "Kingdom: Two Crowns" like when spread across the full width of the scene.
However, as you can see from the image above, I've drawn a pond (as a separate Sprite2D) and I've applied the water shader to the pond. It's done that, but draws the water as a rectangle.
Is there a way to apply this shader to the Sprite2D, but conform to the actual sprite (only the light blue), rather than as a rectangle?

Loading ab buffer using Threads
I want to implement a threaded loading component into my game. I am currently saving all my settings and other level files as bytes externally (meaning not in the res:// folders), as I want to be able to export files and send them to others, so they can use them as well. There is the ResourceLoader.load_threaded_request() method, but that only returns Resources and not PackedByteArrays. As far as I can tell, there is only the FileAccess.get_file_as_bytes() method for importing byte files, which has to run in the main thread (and thus blocking it until the load is complete). Does someone know if I am missing some method here?
EDIT: I have put my fix for this into the comments

Fixed projectiles get stuck in one direction while holding back movement
Solution: I removed the else statement from the integrated_forces process and left the two lines from the condition within the process and it fixed it :) Before:
undefined
func _integrate_forces(state): if Input.is_action_pressed("move_up"): state.apply_force(thrust.rotated(rotation)) if Input.is_action_pressed("strafe_left"): state.apply_force(thrust.rotated(rotation + 4.712)) if Input.is_action_pressed("strafe_right"): state.apply_force(thrust.rotated(rotation + 1.5708)) if Input.is_action_pressed("move_down"): state.apply_force((thrust.rotated(rotation) * -1)) else: state.apply_force(Vector2()) Globals.player_rotation = rotation
After:
undefined
func _integrate_forces(state): if Input.is_action_pressed("move_up"): state.apply_force(thrust.rotated(rotation)) if Input.is_action_pressed("strafe_left"): state.apply_force(thrust.rotated(rotation + 4.712)) if Input.is_action_pressed("strafe_right"): state.apply_force(thrust.rotated(rotation + 1.5708)) if Input.is_action

Persistent variables in tool script
My script sets this value in editor. How can I keep the the changes when saving the scene?
undefined
class Anchor: var offset: Vector3 var connected: Node3D var end: bool var anchors: Array[Anchor]
I found this issue, so I tried fiddling with _get_property_list()
, but that didn't work. It also doesn't seem that I can export the var.
Thanks

Why is _ready() being triggered before the splash end?
I am trying out Godot and I've noticed that when I export the game to linux, the result has a much longer boot time
I'm talking about an 80mb executable for a 3d game and the difference between windows and linux is 0.x seconds vs 10 seconds (the windows computer is more powerful but not by that much...)
I wouldn't care much about that, but during that load time the scene's ready() is triggered and music is played. This causes the cutscene to be desynced with the music and is quite jarring.
Does anyone know why this is happening? Version is 4.1.1 btw
EDIT: after some trial and error I've finallly found the issue. Surprisingly the cause of it was the world environment, more specifically the sky settings, which I had set to high. Bumping them down pretty much fixed the issue.
It's probably a bug, but hey, it works now 🤷

Is there a way to export image files as is? Can't load them as textures on an exported project
My game has options for player customization, it's a number of .png files that are not loaded with the game startup, save for the default ones. Instead, if the player clicks a button, it will load the next file for that part (like, say, hair-2.png
)
This works fine on the editor, but I've just tested an exported version and it doesn't work there, completely failing to find any files within the .pck. If I move the executable back to the project's folder, it works as expected.
Trying to figure out the why, I've also exported via Export ZIP/PCK
, and found out it doesn't actually export any of the .png files, it only exports the .import
files. The actual images are stored in the .godot/imported
folder, each with a long, random(?) string attached to their name: hair-1.png
becomes hair-1.png-t3g9r2he7783y9hut.tcex
I haven't figured out a way to export the .png files as is, so what are my options here? Besides coupling all of the parts in a single image and separating it by fra

Help requested: Screenshot taken but disabled buttons still visible
Hi everyone, I was hoping someone could help me with the following. I have a button that saves a screenshot PNG to the Downloads folder when you press it.
What I want is for the button to disappear after it is pressed, so the screenshot does not include the two menu buttons called "%SaveReport" and "%BackMainMenu".
The code for the save button is listed below:
`
func _on_SaveReport_pressed():
undefined
$"%SaveReport".visible = false $"%BackMainMenu".visible = false print("I've disabled the buttons") print("That means the screenshot SHOULD be button free") take_screenshot() $"%SaveReport".visible = true $"%BackMainMenu".visible = true
`
As you can see, it calls the take_screenshot() function which is listed above:
`
func take_screenshot(): image = get_viewport().get_texture().get_image()
undefined
if OS.get_name() == "Web" or OS.has_feature('JavaScript'): print("We're on the web") # We're on the web image.clear_mipmaps() var buffer = image.save_png_to_buffer() JavaScri

Can someone help with fixing a Godot 3.4 plugin for Godot 4.1?


Hi everyone,
Pretty much as I described in my toot (text copied here). Is anyone aware of what I may need to fix to get this plugin to work again?
I'm hoping someone can help me with a Godot engine question. With the Q&A forum being read-only, I'm hoping Lemmy people can answer this one for me.
I'm trying to use this plugin for HTML5 downloads in Godot 4.1:
https://github.com/Pukkah/HTML5-File-Exchange-for-Godot
It's for Godot 3.4, but I've upgraded my projects and want to stay in 4.1.
Currently, it throws an error “Identifier JavaScript not defined in scope” (see screenshot).
Would anyone have an idea on what to fix here? Thanks!