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?

2 Answers 2

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 ☺

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);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.