Search code examples
user-controlsunity-game-enginegame-developmentjoystick

Which is Right Way to Add Joystick in Unity3d , Adding on Scene Directly or Iniatiating it From Player Scripts


I have to add Joystick control in my Game I had done with Two Approaches both works well for me , but confused Which one to go with.

1) Initiating Joystick Control from Players Object/Script and getting inputs there. 2) Add Joystick Control Directly to Game Scene and then accessing it in player script by findObjectwithTag and getting inputs .


Solution

  • Calling "Instantiate" and "GameObject.Find" is pretty expensive so in my opinion the efficient way is

    1: Add Joystick Control Directly to Game Scene

    2: Create a public object inside player and assign "joystick control" from inspector (Editor).