Questions tagged [events]
Event is action that is usually happenes "outside" of main program thread, but handled inside of it.
284 questions
2
votes
2
answers
923
views
Is it worthwhile to use events when there’s only one subscriber?
I'm trying to determine the best architectural approach for handling communication in Unity, specifically when the interaction is strictly one-to-one.
The Core Design Conflict
I have five crucial, ...
0
votes
0
answers
45
views
how to implement event system with SDL2?
I'm writing a C++ game engine using SDL2 and I have an SDL event loop, but I'm not really sure what I want to do with these events. I know that I'll have systems that will be interested in these ...
12
votes
1
answer
1k
views
Destroying the parent when all children are destroyed
I have a spell system where a the spell is a self-contained game object handling all the logic. When done, it destroys itself. This works great
Then I added a second game object handling animation, ...
0
votes
0
answers
42
views
How to handle draw events without synchronization issues
So in my game I'm using a message queue for everything, very similar to an event manager or event queue pattern. I've seen that lots of people use them, and they decouple when the event fires and ...
1
vote
0
answers
43
views
How to Handle Intermediate State in Event-Sourced Game Architecture for Complex Command Logic
I'm building a turn-based game using an event-sourced-ish architecture. Here's the basic structure:
A dispatcher on the game engine receives commands from the client and routes them to command ...
0
votes
1
answer
161
views
How to control the order of _input_event and _input?
Suppose I have these two classes
...
0
votes
1
answer
92
views
Assigning action without creating closure
I am trying to create a system for daily events in Unity, but I am facing an obstacle where performance and memory are very sensitive for me,The DailyEvent consists of a list of DailyEventAction, ...
0
votes
1
answer
209
views
How can I connect a signal, with specific signal arguments, to an incompatible function in Godot 4 with the UI?
To clarify, I'm attempting to trigger an event on the entry of the player into an Area3D. This event is handled by an ...
0
votes
1
answer
92
views
Public method doesn't show up as a selectable option in a button's On Click event
I have the following public method in a MonoBehaviour attached to a game object in my scene:
...
1
vote
3
answers
105
views
Interaction system with asynchronous interactions
A common approach to creating an interaction system is to use an IInteractable interface. The Player checks for collisions with ...
0
votes
1
answer
106
views
Best way to code event system that has both one-to-one subscription and one-to-several subscription?
I'm trying to create an event system that can be used for all types of events that happen in my game but I'm running into this following problem.
My player HUD needs to be updated whenever an enemy ...
0
votes
1
answer
498
views
Should I remove the listener from UnityEvent similar to normal C# events?
Do I have to always remove UnityEvent listeners in OnDisable(), when I add them in OnEnable() just like I have always did with normal C# events? Does it affect the performance?
0
votes
0
answers
57
views
UI Toolkit event doesn't let me finish writing the value
I use an integer field to indicate the value of the wanted year and I set a maximum and minimum limit for it and I wanted a function to be called when the wanted year value changes to display the ...
0
votes
0
answers
52
views
How to Prevent Subsystems from Responding to Events from Other Game States
I'm writing a game from scratch in C++, using the book Game Coding Complete as a guide. The engine in the book has an event manager which is used to communicate between the game's systems, such as ...
0
votes
1
answer
294
views
Sanity Check on my Idea for an Event System for game
So, I recently started making a small game from scratch, with no engine used(I'm a beginner at this) and I want to create an event system of my own. I want to check if my general idea for it is okay(...
0
votes
1
answer
87
views
Infinite character loop when trying to play Dialogue
I am trying to make a dialogue system in Unity by following this tutorial: (29) 5 Minute DIALOGUE SYSTEM in UNITY Tutorial - YouTube. There is a slight twist to this and that is that I am triggering ...
1
vote
1
answer
642
views
Area2D only detecting body_exited once
I am new to game development, I am practicing by creating a pong game.
I currently have an Area2D set up with a signal listening for ...
1
vote
0
answers
109
views
2D grid game server - interaction system/dynamic blocks
I'm building a Server-side engine for 2D sandbox game similar to Terraria or Starbound.
The language I use is Dart (similar to JavaScript or C#).
Currently I'm trying to figure out how to make a good ...
0
votes
1
answer
548
views
Clicking UI button calls event twice
I've designed a game where, when a button is clicked, the moving point stops. If the button is clicked again, the moving point starts moving again.
I only click on the button once, but the ...
0
votes
1
answer
1k
views
How to design an EventBus(guided by the pub/sub pattern)
I'm working on my game engine, and was faced with the fact, that i don't know how properly design an event system. As a pattern i choose Pub/Sub with an event bus, but i don't know where i should '...
0
votes
1
answer
67
views
3rd Button on UI Seems to not Register the onClick.AddListener()
I have a UIManager meant to control the UI. The UI manager is attached to an empty game object.
The Canvas has three panels, ...
0
votes
0
answers
51
views
Collision detection and damage using call method track
I'm currently implementing damage similar to these two examples, putting the damage logic inside the "call method" track of the player animation.
The problem is that sometimes the game just ...
0
votes
0
answers
94
views
How to make detail tab show information about clicked card?
I'm attempting to create a card game as a new Unreal Dev. Currently I have a UI for the board. That UI has children for the Hands, Field, and Card Details (A window to the side of the field that has a ...
1
vote
1
answer
752
views
Event listeners in code vs persistent event listeners inspector
This is by far the biggest thing I always find myself going in circles over and can never seem to find an approach I'm happy with - setting up regular UnityEvent listeners from code vs. setting up &...
0
votes
1
answer
47
views
Assistance with State Machine Event subscription error? [closed]
My aim is to create events within my various states that will broadcast to other GameObjects when to take certain actions and to send certain data without needing to reference each GameObject.
I have ...
0
votes
2
answers
2k
views
How to get the name of a function added as a listener to a Button's onClick event?
If my button uses AddListener to subscribe a function to listen for clicks:
mybutton.onClick.AddListener(getNameFunction);
Is there a way to get the name of that ...
0
votes
1
answer
2k
views
UI Toolkit not firing button clicked event
I'm using the new UI Toolkit and new Input System together, and I've setup everything correctly the Input Actions has separate input for UI, the Input System UI Input Module is setup correctly, the ...
1
vote
1
answer
3k
views
Is it necessary to unsubscribe from C# events when the event owner has already been destroyed?
The following code throws a null reference exception when I stop the project because touchInterfaceController has already been destroyed.
...
0
votes
0
answers
127
views
AddListener to Button in Prefab
I created a prefab called MapNode and have MapGenerator instantiate a bunch of them at runtime. I want to make the each instance ...
0
votes
0
answers
1k
views
Events and Entity Component Systems?
What are common ways to implement Events in an entity component system ?
Most games typically have following events :
Damage Events
Collision Events
Area of interest Events
Entity Died/Respawn events
...
2
votes
0
answers
270
views
Scheduler for Event Driven Behaviour Tree
The Behaviour Tree Starter Kit (BTSK) on GameAI Pro suggests using a scheduler for an event driven behaviour tree.
To recap: A behaviour tree (BT) is traversed fully every time the root node is ticked ...
0
votes
0
answers
383
views
Will using static events and static instances of a class in multiplayer game in unity cause problems?
I am working on a game system that partly relies on static events and static instance of a class (so not Singleton or static class but just static instance of a class). I am not sure if my system will ...
1
vote
0
answers
617
views
How to distinguish pointer up inside button vs drag-out
I am making a unity mobile game, I have a simple scene and a canvas with a few buttons and these buttons have scripts that detect if the button was pressed and released. Here is the code for doing ...
1
vote
1
answer
166
views
When detecting a keyboard key is released. What happened if the key is released at the end of the game loop?
When detecting a keyboard key is released. What happened if the key is released at the end of the game loop, how could the pollEvent function, which is at the top of the game loop, and it is a brand ...
0
votes
1
answer
466
views
Reference as local variable in Unity c#
In the script below, "btn" is a local variable in OnEnable() method. It's said that local variable is deallocated (lost) when leaving the countaining method. Why this one (btn) is not ?
Nb: ...
0
votes
1
answer
199
views
How to handle mouse wheel events in the Pyxel game engine
I'm trying to handle mouse wheel input (aka scroll wheel) on a plain old mouse.
if pyxel.btn(pyxel.MOUSE_WHEEL_Y):
print(pyxel.mouse_wheel)
This never triggers....
0
votes
0
answers
71
views
Unity code design - Events
I am aiming to create a Unity project with a code structure similar to ECS.
I want the code to be consistent, easy to integrate extend and expand if multiple developers will work with it.
By that I ...
0
votes
1
answer
700
views
Why does assigning an empty delegate to this Unity Event Action on construction make it work? (But it is dead/broken without it?)
I am learning about Actions/Events in Unity and just built a system around them which works. However, it seems I just got lucky and I'm not sure why.
Roughly, my class in a simple illustrative form (...
0
votes
2
answers
1k
views
Optimal implementation for effects in a card game
I am working on a card game in Unity and want to implement a system where I can create card effects that happen when certain events are triggered.
The events could be anything from when a card is ...
0
votes
1
answer
252
views
How to check whether the user completed their missions?
I am working on a coding/gaming application.
I am currently stuck in the daily missions part.
So, the user receives some missions each day, such as solving a problem, following another user, or ...
0
votes
0
answers
165
views
Pygame unaccurate key press event handling
I have a problem with my game_over() function in Pygame.
When the player loses, the game_over() function gets executed but since ...
0
votes
0
answers
1k
views
How to handle various collision effects within an Entity Component System?
Let's say we have three enemies, a bear trap, a fire trap, and a minotaur. When you walk over the bear trap, the game spawns an invisible entity that, upon the player colliding with it, slows the ...
0
votes
1
answer
2k
views
How could I intercept a save scene action being run in Unity?
How could I intercept a save scene action being run in Unity?
There is some code I would like to run in editor whenever a scene is saved. Is it possible for me to detect somehow when a scene is saved?
0
votes
1
answer
208
views
Best way to handle events for a turn base game?
I'm looking for the best way to handle events for a tactic game in Unity. Every unit may need to react to different events (turn start, end, on damage to self, on damage to other, on kill, etc...).
At ...
2
votes
2
answers
2k
views
Is it better to connect signals in source code or with the IDE feature?
In Godot IDE, what are the advantages and the caveats of using the visual IDE to connect signals to listerners instead of doing this:
...
0
votes
1
answer
293
views
C# Events in Unity to separate GameObject features into Components
Broadly speaking, this is a question about how to separate my game object's code into distinct feature components that can be added and removed as needed.
More specifically, I am trying to achieve ...
1
vote
1
answer
1k
views
Method subscribed to an event is called twice for every time the event is raised [closed]
I am trying to make an inventory system in Unity with ScriptableObjects and a text driver that displays the contents of an inventory. So far the code looks like this:
-An InventoryObject is defined as ...
0
votes
1
answer
197
views
How to make a script on a prefab act on a particular scene instance?
I am building Actionables (Windmill, Coal) on a Planet by hovering the mouse over the Planet and clicking on it.
Actionables are prefabs, which have an Actionable ...
1
vote
0
answers
523
views
How to design a character damage system with ECS architecture?
I am developing an game with ECS architecture and trying to design a character damage system.
Does the following design fits into ECS conception and will it be extendable in future?
I have an ...
0
votes
1
answer
1k
views
Press and hold camera movement with mouse in new Input System?
I am transitioning to the new movement system and am having trouble figuring out how to move the camera when a mouse button is pressed and held.
Here's how I did it before:
...