Skip to content

TheHotPathShow/Episode-11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image

1. Input Handling basics

Main Input System functions powering most of the project!

InputUser.listenForUnpairedDeviceActivity = 4;
InputUser.onUnpairedDeviceUsed += (control, _) =>
{
    if (!(control is ButtonControl)) 
        return;
    if (control.device.description.deviceClass == "Mouse") 
        return;

    // Pair the device with the user, making the playerController only act with the given device
    var user = InputUser.PerformPairingWithDevice(control.device);
    var playerController = new KyleInput();
    playerController.Enable();
    user.AssociateActionsWithUser(playerController);
    
    // if keyboard also pair with mouse
    if (control.device.description.deviceClass == "Keyboard")
    {
        var mouse = InputSystem.devices.FirstOrDefault(d => d.description.deviceClass == "Mouse");
        if (mouse != null)
            InputUser.PerformPairingWithDevice(mouse, user);
    }
    
    // Do something with `playerController` or store it for later use
    
    // Listen for one less device
    InputUser.listenForUnpairedDeviceActivity--;
};

Written by: Dani K Andersen (@dani485b)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published