how to set joystick to follow camera's position?
【Question】 I want the same as the monster hunter this game as the lens does the conversion
The direction of the virtual joystick is also adjusted at the same time
So that the movement of the rocker is determined by the lens to the left of the rocker will move to the left of the moment
https://www.youtube.com/watch?v=wiyWbivo6Xo
this is my problem video:
https://www.youtube.com/watch?v=prTUYlM5_Y4
my joystick compoment:
using UnityEngine; using System.Collections; public class PlayerController : MonoBehaviour {
[System.Serializable]
public class AnimatorParameters{
public string Run;
public string horizontal;
public string vertical;
}
private Animator target;
public float speed = 2.5f;
public AnimatorParameters parameters;
private Vector3 direction ;
private Coroutine cououtine;
//
public AudioSource audio;
public AudioClip foot;
private Component touch;
void Awake(){
target = GameObject.Find ("Yuka").GetComponent<Animator> ();
touch = GameObject.Find ("Main Camera").GetComponent<Example_Hand>();
}
private IEnumerator Move(){
while (true) {
this.target.transform.position += this.direction * Time.deltaTime * this.speed;
this.target.transform.forward = this.direction * Time.deltaTime * this.speed;
yield return null;
}
}
public void BeginMove(){
//this.target.SetBool (this.parameters.Run, true);
this.target.Play ("Run_2");
this.cououtine = StartCoroutine (this.Move ());
}
public void EndMove(){
touch.GetComponent<Example_Hand>().enabled = true;
//this.target.SetBool (this.parameters.Run, false);
this.target.Play("Idle_C");
StopCoroutine (this.cououtine);
}
public void UpdateDirection(Vector3 direction){
touch.GetComponent<Example_Hand> ().enabled = false;
this.direction.x = direction.x;
this.direction.z = direction.y;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612115027im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
c# Mobile Joystick issues - implementing joystick controls into movement and camera script 0 Answers
Roll a ball, treating where the camera is rotating as forward? 0 Answers
How to make a camera follow a ball from behind? c# 3 Answers
Render to minimap on command 1 Answer
Third Person Shooter Controller 0 Answers