Search Unity

Plz help me

Discussion in 'Editor & General Support' started by Funyguy, Jun 17, 2021.

  1. Funyguy

    Funyguy

    Joined:
    Oct 13, 2020
    Posts:
    11
    If somone can help me this code is for a joystick and i want when i move the to the left or the right to rotate
    Code (csharp):
    1.  using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. public class JoystickControler : MonoBehaviour
    5. {
    6.     public float speed;
    7.     public Joystick Joystick;
    8.     public Rigidbody rb;
    9.     public void FixedUpdate()
    10.     {
    11.         Vector3 direction = Vector3.forward * Joystick.Vertical + Vector3.right * Joystick.Horizontal;
    12.         rb.AddForce(direction * speed * Time.fixedDeltaTime, ForceMode.VelocityChange);
    13.     }
    14. }
    Ps. I 4 month's ago i started using unity
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
  3. Funyguy

    Funyguy

    Joined:
    Oct 13, 2020
    Posts:
    11
    Ok, thank you. but how can i implement it in the code