- Home /
Joystick movement for 3d mobile player
Hey!
I'm having some issues with my players movement, I want to update my current script so that player rotates when the joystick moves horizontally. can anyone please help me with this.
public class WorldInteraction : MonoBehaviour
{
public static WorldInteraction instance;
public UnityEngine.AI.NavMeshAgent playerAgent;
protected FloatingJoystick joystick;
public Rigidbody rigidbody;
public Vector3 velocity1;
void Start()
{
instance = this;
playerAgent = GetComponent<UnityEngine.AI.NavMeshAgent>();
//find things in scene
joystick = FindObjectOfType<FloatingJoystick>();
}
void Update()
{
//code that allows character to move
velocity1 = new Vector3(
joystick.Horizontal * 10f,
rigidbody.velocity.y,
joystick.Vertical * 10f) ;
rigidbody.velocity = velocity1;
}
}
I would really appreciate it if there was also a way to be able to rotate the camera with a TouchField, i've been unable to find any tutorials that I can follow along for the interactive screen part.
Comment
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Smooth transition from 360 to 0 degrees 1 Answer
Multiple Cars not working 1 Answer
How to drag objects from UI into scen 3 Answers
Overlay 2 scenes 1 Answer