Hi everyone I'm completely new to DOTS but have a project or two worth of Unity experience. The first problem I'm tackling is getting user input (which tends to involve lots of managed code) in systems that inherit from ISystem (which I believe only work with unmanaged types).
I followed this video: https://www.youtube.com/watch?v=bFHvgqLUDbE and, from my understanding, the way to read input while still being DOTS friendly is making a system inheriting from SystemBase that takes care of reading all the player inputs the usual way from our beloved managed classes and then puts them in an IComponentData struct that the rest of the system can read from while still following DOTS principles. hopefully I got that right.
Anyways, doing this for continuous inputs, like movement, felt straightforward enough. Every frame, you read the movement input given by Unity and then store it in a PlayerMoveData component or similar.
But when it comes to inputs like shooting or jumping, the video suggests an event-driven w/ tag components approach , but kind of glosses over any explanation, which leads me to my questions:
- if you just want to know if the user is pressing a button, can't you have a component with boolean values representing whether certain buttons are pressed/not pressed
i.e.
public struct PlayerInputData : IComponentData
{
public bool JumpButtonPressed;
public bool AttackButtonPressed;
...
}
I feel like setting and reading boolean values is much cheaper than adding tag components to the player and querying for them?
- if you do work with tag components, what's the difference between enabling/disabling them vs. adding/removing them?