Question by
jonathanbebawi · Oct 21, 2020 at 09:36 PM ·
c#vector3arrow
I'm trying to make an arrow that dynamically points the same direction as the player is traveling
Hello, I'm making a small flying race game prototype (think pod racing in canyons) and I want to make an arrow that shows up in front of the player character that will point where he is pointing the stick. so, he points left, the arrow points left.
private Gamepad gamepad;
public Vector2 LeftJoystick;
public Image arrow;
void Start()
{
gamepad = Gamepad.current;
}
// Update is called once per frame
void Update()
{
Vector3 arrowPos = Camera.main.WorldToScreenPoint(this.transform.position);
arrow.transform.position = arrowPos;
LeftJoystick = new Vector2(gamepad.leftStick.x.ReadValue(), gamepad.leftStick.y.ReadValue()) * 90.0f;
arrow.transform.localEulerAngles = new Vector3(0, 0, gamepad.leftStick.x.ReadValue());
//arrow.rectTransform.LookAt(LeftJoystick);
this is the code i've tried to use but neither of those transforms work, im using a canvas and an image to put the arrow on screen.
thanks for any help you could give
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613014257im_/https://answers.unity.com/themes/thub/images/avi.jpg)