#Player Input component for DOTS

1 messages · Page 1 of 1 (latest)

modest loom
#

Hello, i would like to try and use the player input component the new input system provides for DOTS. What's the best method to go about this?

I assume i need to somehow read the data in a system and write it to a component that is made for the data?

restive girder
toxic pulsar
#

By writing input data to a singleton struct component, you make burst compatible code

modest loom
#

Ok, i will look into the singleton struct. I think that’s likely the way i would want to do it

wintry sequoia
#

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