Godot

5925 readers
157 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

[email protected]

Credits

founded 1 year ago
MODERATORS
476
122
submitted 1 year ago by mac to c/godot
477
478
 
 

Not sure if good or not, but might be interesting for people trying to switch from Unity.

479
 
 

I'm trying to make an action where the player can pick up and throw a rigidbody3d. I want the object to act like a rigidbody when not in the player's hands, but when it is, I want to set the rigidbody position to match a marker3d which is a child of the player.

What's the best approach to something like this? Should I be using integrate forces here? I'm not sure I really understand when and when not to use it.

480
 
 

In case you're suddenly facing the task of porting an entire game over due to capitalist nonsense or something

481
 
 

@godot's timing on announcing the development fund is just *chef's kiss*. The landing page was out there without announcement for some time, I guess they simply took the opportunity as they should have :)

482
 
 

I made a blog post about my experience switching from Unity to Godot earlier this year, and some tips for Unity devs.

483
26
submitted 1 year ago by mac to c/godot
484
14
submitted 1 year ago by mac to c/godot
485
486
487
3
threaded add_child() ? (lemmy.blahaj.zone)
submitted 1 year ago by [email protected] to c/godot
 
 

I'm struggling with adding nodes to the scene without a frame or two dropping for larger scenes. What are the chances that it will ever have some sort of threaded version, so that it just adds the node in the background while the main thread can continue displaying them graphics?

488
24
Godot XR Update (godotengine.org)
submitted 1 year ago by [email protected] to c/godot
489
 
 

They're free to use commercially, and some of them are pretty neat if you want to show off support for the engine in your game. Preview image:

A screenshot previewing most of them

490
 
 

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():

$"%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()

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()
	JavaScriptBridge.download_buffer(buffer, fileName)

if OS.get_name() != "Web" or !OS.has_feature('JavaScript'):
	# We're not on the web
	print("We're not on the web")
	
	var docs = OS.get_environment("HOME") + "/Documents"
	
	var title = str(docs + "/results",global_ints.observed_person_name, global_ints.observation_minutes,".png")
	
	print(title)
	
	var _saveimage = image.save_png(title)
	
	if OS.get_name() != "OSX":
		print("We're not on MacOS")
		var _openfolder = OS.shell_open(docs)
	
	if OS.get_name() == "OSX":
		print("We're on MacOS")
		
		var _openfolder = OS.shell_open("file://" + docs)

`

The code works. The screenshot is taken and it's saved to the Downloads folder and MacOS/Windows/Linux open up the Downloads folder straight after.

For the life of me, I can't figure out why the Back & Screenshot buttons ( "%SaveReport" and "%BackMainMenu") that I turn invisible BEFORE I call take_screenshot() end up being in the screenshot. Every single time.

Anyone have any ideas?

Thank you!

491
 
 

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!

492
493
23
submitted 1 year ago by mac to c/godot
494
 
 

I'm trying to make something in 2d where once the player reaches the end of the level, they're back at the beginning and it just keeps going like that. I could imagine how this could be done in terms of setting the player position, but if I have a scrolling parallax background, how would I make that match up reliably?

495
29
submitted 1 year ago by mac to c/godot
496
497
498
19
submitted 1 year ago by mac to c/godot
499
13
submitted 1 year ago* (last edited 1 year ago) by ICastFist to c/godot
 
 

I've been looking into some tutorials, mainly this one - https://www.gotut.net/custom-key-bindings-in-godot-4/

My particular problem is that this and every other tutorial of key rebind only deals with 1 action = 1 keybind, while I want my actions to have 3 keybinds: 2 from the keyboard, 1 from a controller. Because of that, I can't simply empty the InputMap of a given action and add the newly pressed key.

After quite some time thinking and testing, I've managed to cobble together this code (based on the one from the link above) that works as I want: it removes the previous keybind and adds the new one, without messing any of the previous keys.

func _input(event):
	if !current_button:
		return
	if event is InputEventKey and $keypress.visible:
		var action: String
		match current_button.name:
			"rebind_jump":
				action = "game_jump"
		#Match repeat for each button/action, also "duplicated" for each of the alternative keys/buttons, as "alt_game_jump", etc
		#The following lines happen after the match defines the action 
		rebind(event,action, current_button.text)
		current_button.text = event.as_text()
		current_button = null


## The rebind function is called by sending the event, a string of the action proper and the button's current text as the "oldkey"
## rebind(event, "game_jump", $rebind_jump.text)
## After the event call, the button's text is set like this: $rebind_jump.text = event.as_text()

func rebind(event: InputEvent, action: String, oldkey:String):
	var existing : Dictionary = {}
	var key: String
	for ia in InputMap.action_get_events(action):
		#The split(" ") below happens because physical key presses are sent as "E (Phyisical)" or "Ctrl (Physical)"
		if ia.as_text().split(" ")[0] != "Joypad":
			key = ia.as_text().split(" ")[0]
		else:
			key = ia.as_text()
		existing[key] = ia
	for acts in InputMap.get_actions():
		#Removes the key from any other events 
		InputMap.action_erase_event(acts, event)
	InputMap.action_erase_event(action, existing[oldkey])
	InputMap.action_add_event(action, event)

While it works as is for keyboard rebind, I haven't tested it with a controller, as I don't have one around to test.

But my main question is: is this "ideal"? Is there a better/easier way to do this, rebind an action substituting only one key?

EDIT: Did a few tweaks on the code. One thing that I haven't figured out yet is a way to update a key that was already bound to another button. For example: if "Ctrl" is bound to jump, and I bind it to attack, it automatically unbinds from jump. If I then try to bind anything to that specific jump button, I'll get a Invalid Index error at the InputMap.action_erase_event(action, existing[oldkey])

500
 
 

I was seeing a video on common tricks FPS games use, and one of them was having the weapon render on a higher and/or separate layer to avoid having it clip with other objects in the world. How would something like this be done in Godot?

view more: ‹ prev next ›