Search Unity

Gamepad.SetMotorSpeeds cpu usage is very high with Bluetooth controllers

Discussion in 'Input System' started by nikescar, Aug 31, 2021.

  1. nikescar

    nikescar

    Joined:
    Nov 16, 2011
    Posts:
    165
    Setting the rumble motors in Update() using gamepad.SetMotorSpeeds(lowPower, highPower) results in 0.8ms of CPU time in a scene that takes around 5ms total. Considering I am running physics on 8 cars with 6 of their own child rigidbodies on hinges plus the complex math code, it didn't seem right that just assigning rumble values to a controller should use so much CPU.

    The controller is one of the new official Xbox controllers. I connect via bluetooth usually but decided to try USB. All of the sudden CPU usage for SetMotorSpeeds is 0.03ms. Seems IInputRuntime.DeviceCommand is blocking as it waits for a response from the controller that the command was recieved.
     
    Last edited: Aug 31, 2021
    samasamas likes this.
  2. samasamas

    samasamas

    Joined:
    May 30, 2022
    Posts:
    1
    I appear to be having similar issues, using an Xbox Series controller wirelessly (with the official xbox wireless dongle) and unity 2022.3.15f1. Calling Gamepad.SetMotorSpeeds results in up to 10ms CPU spikes, while doing so with the controller connected via USB reduces it down to 2ms or less.

    Were you able to find a solution?
     
  3. Caresilabs

    Caresilabs

    Joined:
    Jul 8, 2017
    Posts:
    1
    I'm seeing the same issue. Did you solve it?
     
  4. nikescar

    nikescar

    Joined:
    Nov 16, 2011
    Posts:
    165
    The solution is not to use Unity. When I reported the issue to Unity, they marked it as "Will not fix" or whatever. I even tracked down the single line of code that they would need to change. What a bunch of dummies
     
    Last edited: Feb 8, 2024
  5. neon8100

    neon8100

    Joined:
    Mar 25, 2015
    Posts:
    9
    Yep, got the exact same issue. Using an Xbox One controller. Basically halves my frame-rate from 200fps to 100. It's absurd.