godot | streaming real-time event processor | Game Engine library
kandi X-RAY | godot Summary
kandi X-RAY | godot Summary
Godot is a streaming real-time event processor based on Riemann written in Node.js.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Registers a reconnection attempt .
- connect to the next connection
- Respond to the server .
- wrap stream
- Add defaults to object
- Helper function for checking a given key .
- Create an error handler .
- Checks for a given tag
godot Key Features
godot Examples and Code Snippets
Community Discussions
Trending Discussions on godot
QUESTION
I'm currently working on my Pong game project using Godot.
Everything is working well but there's only one problem.
After one side gets scored, the ball is stuck in the middle and not working.
What should I add? Here is my code:
...ANSWER
Answered 2022-Apr-17 at 00:06I'm guessing the ball is a RigidBody2D
.
They are intended to be moved by the physics engine, and moving them directly (e.g. setting position
) can cause problems. This one of the reason I often recommend beginners to use KinematicBody
(2D
), so they are not "fighting" the physics engine.
Anyway, that is a cop-out answer. You want to teleport a RigidBody2D
, let us see how to do it.
The following is - in my opinion - the elusive proper way to teleport a RigidBody2D
:
QUESTION
Think of an RPG game where you might need to present a list of buttons. A user might enter a room where they have to select from a series of options (buttons). Is there a type of container/panel that would show clickable buttons horizontally, but wrap if needed?
The best analogy I can think of to picture the situation is, Imagine needing to click on an item in a backpack, but each item is potentially a different width. (I can make them all the same height but the width then varies)
...ANSWER
Answered 2022-Apr-01 at 08:06Godot 3.5 (currently in beta) introduces HFlowContainer
and VFlowContainer
that will serve the propuse described.
The HFlowContainer
will fill a row and when they overflow, it will add a new row and continue there. The VFlowContainer
will work on a similar fashion but with columns.
For older versions of Godot you can use the HFlowContainer
addon which you can find it in the asset library (here). Note that there is no VFlowContainer
counterpart.
As everything on the asset library it is free and open source, so feel free to read the code and modify it, which can be serve as starting point if you want to make your own custom Container
.
Container
The gist of making a custom Container
is that it must position its children.
For that effect you react to NOTIFICATION_SORT_CHILDREN
in the _notification
method. You might also want to react to NOTIFICATION_RESIZED
.
You can have a method - which I'll call layout
- that you call when you get the notifications:
QUESTION
I've just gotten into coding, and I'm trying to make a simple duck shooter game in Godot 3.0. I have a crosshair(Kinematicbody2D) and ducks flying across the screen(also KinematicBody2D). Is there a way that I can detect if the duck and crosshair are overlapping? Like an if statement?
In case anyone's curious, this is the code I've got so far (This is the duck script and the comments are what I need to add in on that line).
ANSWER
Answered 2022-Mar-26 at 00:48I don't think it makes sense to make the crosshair into a physics body. Does it collide/push/bounce off obstacles? Much less a KinematicBody2D
. Do you need move_and_slide
or can you get away with writing the position
? So here are some alternatives to go about it, before I answer the question as posted.
Input Pickable
If you want to find out if the pointer interacts with a physics body, you can enable input_pickable
, and you will get an "input_event"
signal whenever it happens.
Mimic input Pickable
Otherwise you can get the position of the pointing device in an _input
event and query what physics objects are there. Something like this:
QUESTION
Assume we have a main menu with multiple buttons, and we have a text file which contains data behind button 1, button 2, etc.... The text data is loaded into an array of dictionaries.
We are loading a scene like this:
...ANSWER
Answered 2022-Mar-23 at 09:56
# Global singleton provides a data set, i.e.
If you already have an autoload (singleton), I would put there the information you want to give the other scene, and have the other scene read it.
I understand that change_scene() is "deferred" so we cant just straight away call a "setter" function for this scene, or can we?
Correct, you can't. For the instant where the new scene is loaded the current one is already unloaded, so it can't really call a method on the new one.
Unless you take control of the process. See Change scenes manually.
QUESTION
I have a script attached to an AnimationPlayer
node and it does some long calculations,
so in order to avoid the game engine from hanging while those calculations take place
I created a separate thread for that function,
but the seek()
function doesn't update the animation despite adding update=true
I've narrowed it down to this simple example:
...ANSWER
Answered 2022-Mar-20 at 12:34After testing, it appears to me that it works with a couple caveats:
- You need to take proper care of the thread. Which I explain below.
- The change will not be reflected in the Animation panel. However you should be able to see the animation take effect on the nodes.
Once done properly it works on Godot 3.2 or newer. However, starting with Godot 3.4 I could be more sloppy with how I handle the thread and it would still work.
First of all, you need to call wait_to_finish
when the thread ends. Not doing it will prevent proper cleanup. If you don't have code waiting for the thread to finish, you can add this at the end of the thread code:
QUESTION
Ok, I've been using Godot for a while now, and haven't really had any issues. But, after I added an area2D to detect the player and teleport them as shown below that I run into issues. Every time I start the game, the console shows that both of the functions have already been run, even though the starting location is nowhere near the area2Ds. In addition, because they run in enter -> exit order, it spawns me at the exit of the tunnel, instead of the start of the map.
...ANSWER
Answered 2022-Mar-10 at 23:40Are you, by chance, instancing the player character, adding it to the scene, and then setting its position (in that order)?
That is a common reason for this problem. What happens is that it collides with the areas once you add it to the scene but before you set its position.
To solve it set the global position before adding it to the scene.
You could temporarily disable the behavior by any of these means:
- Temporarily changing the layers and mask to avoid the collision (you can do it with
set_collision_layer_bit
andset_collision_mask_bit
). - Temporarily disabling collision shapes (by setting
disabled
totrue
. However, useset_deferred
to avoid disabling it while Godot is still doing physics computations) - Temporarily adding collision exceptions (by calling
add_collision_exception_with
andremove_collision_exception_with
). - Having a flag that you can check in the function that takes the signal to decide if it should take effect or not.
- Connecting the signals from code once, so they are not connected beforehand.
QUESTION
I'm trying to connect a few sprites together like this:
but everytime I zoom out, I get gaps & dislocations
I've even tried turning off filter according to this article but I'm still getting the same problem.
Maybe I can fill the gaps with a little bit of padding and offset but the dislocations
are the main concern
how do I fix this? and make it seem & move like it's a single image?
ANSWER
Answered 2022-Mar-10 at 14:04Your scene tree might be causing this problem. Your positions are all children of the one before. Make pos1, pos2 and pos3 siblings
QUESTION
I'm working on a little project in Godot with Procedural Terrain generation.
I need a really basic Camera controller that instead of jumping can fly. Even the Fps controller from the Godot official's Fps Tutorial is overkilled for my needs. I'm quite new to Godot and GDScript, and even if I know well C#, I don't know hot to move in Godot with it (I prefer GDScript in Godot because of the lack of an internal editor for C#).
Can anyone please help me? Thanks
ANSWER
Answered 2022-Mar-05 at 18:08For testing purposes, my go to is "Simple Free-Look Camera" by adamviola, you can find it on the asset library. When you download it, it will give you a camera.gd
script that you can attach to a Camera
in your scene (dragging the file from the File System panel to the Scene panel will do). Make the current
of the Camera
is set true
. And that is all it takes.
The script mimics the basic movement of the editor camera, so you press right click to look around and WASD to fly. Q and E move vertically. And you can use the mouse wheel to change the fly speed.
Also, just like everything in the asset library it is gratis (which is why it is not an asset store). Also it is open source. So you can open it and study the code. And also it is libre, so you are also free to modify however you want. The above description of the controls should also help as starting point for what to look for in the code.
What follows is a short explanation of what the code of camera.gd
does.
You can find in the code that it uses Input.set_mouse_mode
to capture the mouse when you press right click. And it will store the relative
motion when it gets a InputEventMouseMotion
(this is in _input
by the way) for later rotating the Camera
using a combination of rotate_y
and rotate_object_local
(that part is in _update_mouselook
). Horizontal mouse motion is translated to yaw, and vertical mouse motion is translated to pitch, the code also clamps the pitch.
It will also keep track of the state of the keys it is interested in. You can find the variables _w
, _s
, _a
, _d
, _q
, _e
on the top of the script, and updated on _input
when it gets a InputEventKey
. The state of those keys is used to compute a direction vector - on which it applies velocity and acceleration - and finally move the Camera
with translate
(you can find that on _update_movement
). Note that translate
is affected by the orientation of the Camera
, so the z
axis is where you are looking at.
The mouse wheel input is also taken on _input
, and it updates a velocity multiplier which is applied in _update_movement
.
QUESTION
A Button
in Godot can only hold a single line of text. I can overcome this limitation by placing RichTextLabel
node inside the button.
Now the button can contain more lines of text, but its height doesn't change automatically when more lines are needed. Instead the text just overflows:
Of course I can manually resize the button to be higher, but I'd like this to happen automatically depending on the amount of text inside. Specifically, I'm generating a list of these buttons programmatically and showing inside a HBoxContainer
, with some buttons having longer and other shorter text.
Is there a way to achieve this with Godot layout tools?
...ANSWER
Answered 2022-Mar-04 at 00:51Since the Button
is in a Container
, it is in control of its rect_size
. The best we can do is specify a rect_min_size
. There is no layout preset to have a Control
depend on children Control
. So, to answer the question as posted: No, we cannot achieve this with Godot layout tools. We need some scripting.
We need to set the rect_min_size
for the Button
depending on the RichTextLabel
. We can ask it for the height of its content with get_content_height
. Which also means we need to set the width beforehand. However, it will not update right away when we set the text (we are going to use yield
).
Apparently you don't want the Container
to control the height of the Button
. If that is the case, I think you can remove all the flags from size_flags_vertical
.
About the width, since as I was explaining before we need to set the width to get the height… I suggest you let the Container
expand the width of the Button
as much a posible. Which mean setting both the Fill and Expand flags on size_flags_horizontal
.
Then, with the RichTextLabel
properly set to take as much width of the parent Button
as possible, you can read it height, and use it to set the height of the rect_min_size
of the Button
.
One more thing: you want to set the mouse filter of the RichTextLabel
to Ignore or Pass, or it will prevent pressing the Button
.
This is the code I came up with:
QUESTION
I have a KinematicBody2D (player) and an Area2D (ladder). With the following code I get clean enter and exit events that happen as the player touches and leaves the Area2D object e.g. touch Area2D and a single "enter" prints. Move back and a single "exit" prints.
...ANSWER
Answered 2022-Feb-28 at 17:57Godot is doing what you are telling it to do.
The call set_collision_layer_bit(0, false)
would be disabling the collision between the KinematicBody2D
and the Area2D
which means they would no longer be colliding. And since they stop colliding, you get a "body_exited"
signal.
I want to turn off collisions so the player can pass the object and re-enable them when he passes and leaves the Area2D object
The Area2D
do not stop physics bodies (StaticBody2D
, KinematicBody2D
, RigidBody
). There must be something else doing that. For example, if you added a StaticBody2D
to the ladder, or made it with a TileMap
where the tiles have collision, those could stop your KinematicBody2D
.
I think the simplest approach would be to put the Area2D
in a different collision layer, so you can disable the collision that stops the KinematicBody2D
without disabling the Area2D
.
Other options to disable collisions include:
- Disabling a
CollisionPolygon2D
orCollisionShape2D
by settingdisabled
totrue
. Note: you cannot to do this while Godot is resolving collision response. To avoid that, useset_deferred
to change the value ofdisabled
. - Adding a collision exception by calling
add_collision_exception_with
. Useremove_collision_exception_with
to remove the exception. This is a more fine grained tool that should be used sparingly (if you are adding lots of exception, prefer using collision layers and masks).
Addendum: An option for the TileMap
is to have two version of the tile, one with the collision and one without it. And the swap them in runtime with set_cell
. However, consider using a scene instead. In fact, you might want to set the cells in the designer and replace them with actual scenes in runtime. See How to use SCENES in a TILEMAP(And 9 MORE TRICKS) | Godot Engine. You may even do it only when the player gets nearby, see How to create large Sidescrolling Map in Godot?.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
Install godot
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page