0

I want to know if there is a way to control a 3d boat with a joystick to publish the game on android devices. The boat moves only when using desktop keys. I am using this C# code:

void Update ()
{
    float h = Input.GetAxis("Horizontal");
    float v = Input.GetAxis("Vertical");

    rbody.AddTorque(0f,h*turnSpeed*Time.deltaTime,0f);
    rbody.AddForce(transform.forward*v*accellerateSpeed*Time.deltaTime);
}

How to change it to have a moving boat on android with a joystick?

spenibus
  • 4,339
  • 11
  • 26
  • 35
WalaaJ
  • 11
  • 2

2 Answers2

1

Why not try import the Character Controller asset.There is a prefab with a joystick in it. Don't forget to click the tick button if this works ☺

Rowan Harley
  • 326
  • 1
  • 3
  • 13
0
void Update ()
{
     float h = CrossPlatformInputManager.GetAxis("Horizontal");
     float v = CrossPlatformInputManager.GetAxis("Vertical");

    rbody.AddTorque(0f,h*turnSpeed*Time.deltaTime,0f);
    rbody.AddForce(transform.forward*v*accellerateSpeed*Time.deltaTime);
}