#Player Input component for DOTS
1 messages · Page 1 of 1 (latest)
Your assumption is correct.
By writing input data to a singleton struct component, you make burst compatible code
Ok, i will look into the singleton struct. I think that’s likely the way i would want to do it
Doesn't have to be a singleton
I recommend looking at InputUser, which is a struct and you can use that as part of components
For example
/// <summary>
/// A LOCAL <see cref="UnityEngine.InputSystem.Users.InputUser"/> for usage with Entities.
/// This will always stay alive, and won't be related to anything in-world.
/// </summary>
[DebuggerDisplay("LocalUser, id = {InputUser.id}, activationDevice = {ActivatorDeviceID}, activeDevice = {ActiveDeviceID}")]
public struct LocalUser : IComponentData, IComparable<LocalUser>, IEquatable<LocalUser>, IDisposable
{
/// <summary>
/// The Input User provided by Unity's Input package.
/// </summary>
public InputUser InputUser;
/// <summary>
/// The <see cref="InputDevice.deviceId"/> that created this user.
/// </summary>
/// <remarks>
/// Equals to a <see cref="InputDevice.deviceId"/> within the input user's <see cref="InputUser.pairedDevices"/> array.
/// </remarks>
public readonly int ActivatorDeviceID;
/// <summary>
/// The <see cref="InputDevice.deviceId"/> currently being used.
/// </summary>
/// <remarks>
/// Equals to a <see cref="InputDevice.deviceId"/> within the input user's <see cref="InputUser.pairedDevices"/> array.
/// The same as <see cref="ActivatorDeviceID"/> when the user is created.
/// </remarks>
public int ActiveDeviceID;
public LocalUser(InputUser inputUser, int activatorDeviceID)
{
InputUser = inputUser;
ActivatorDeviceID = activatorDeviceID;
ActiveDeviceID = activatorDeviceID;
}
You will however have to figure out how to pair up devices with users
I recommend looking at the component that manages that, I cannot recall its name though