Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Dualshock 4 lightbar

Discussion in 'Input System' started by asatrian, Mar 18, 2020.

  1. asatrian

    asatrian

    Joined:
    May 11, 2017
    Posts:
    8
    How can I properly initialize the dualshock4 ? is there any sample code ro change the lightbar ?
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Code (CSharp):
    1. var gamepad = (DualShockGamepad)Gamepad.all[0];
    2. gamepad.SetLightbarColor(Color.red);
     
  3. asatrian

    asatrian

    Joined:
    May 11, 2017
    Posts:
    8
    it detects my dualshock but it doesn't work. The light bar is in default color white. Is there any specific dualshock 4 setup that I need to go on windows ?
     
  4. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Is the controller connected via USB or via Bluetooth?
     
  5. asatrian

    asatrian

    Joined:
    May 11, 2017
    Posts:
    8
    It is connected via bluetooth. Is using DS4Windows alright ? or I just need to turn off the DS4Windows and paired it directly ?
     
  6. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    With DS4Windows turned off, the controller should be working both wired and over Bluetooth.
     
  7. TopSkillGamer

    TopSkillGamer

    Joined:
    Jun 9, 2020
    Posts:
    4
    How can I make this work? I'm kinda new to C# and I do not know where to put it, it's throwing a bunch of errors at me...

    EDIT: upload_2020-8-28_23-19-29.png
    upload_2020-8-28_23-19-53.png
     
  8. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    You could just click that "Show potential fixes" link and VS would suggest you alternative fixes. In this case you are missing:
    Code (CSharp):
    1. using UnityEngine.InputSystem.DualShock;
    additionally, there's a typo in the example, you actually need to write:
    Code (CSharp):
    1. gamepad.SetLightBarColor(Color.red);
    instead of
    Code (CSharp):
    1. gamepad.SetLightbarColor(Color.red);
    (note capitalized B in SetLightBarColor)
     
  9. PoisonousPurple

    PoisonousPurple

    Joined:
    Aug 10, 2020
    Posts:
    1