Hello, im having a problem the error cs0019. Error: Joystick.cs(73,11): error CS0019: Operator `/' cannot be applied to operands of type `UnityEngine.Vector2' and `UnityEngine.Vector2' The code: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class Joystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPointerUpHandler { public float Horizontal { get { return (snapX) ? SnapFloat(input.x, AxisOptions.Horizontal) : input.x; } } public float Vertical { get { return (snapY) ? SnapFloat(input.y, AxisOptions.Vertical) : input.y; } } public Vector2 Direction { get { return new Vector2(Horizontal, Vertical); } } public float HandleRange { get { return handleRange; } set { handleRange = Mathf.Abs(value); } } public float DeadZone { get { return deadZone; } set { deadZone = Mathf.Abs(value); } } public AxisOptions AxisOptions { get { return AxisOptions; } set { axisOptions = value; } } public bool SnapX { get { return snapX; } set { snapX = value; } } public bool SnapY { get { return snapY; } set { snapY = value; } } [SerializeField] private float handleRange = 1; [SerializeField] private float deadZone = 0; [SerializeField] private AxisOptions axisOptions = AxisOptions.Both; [SerializeField] private bool snapX = false; [SerializeField] private bool snapY = false; [SerializeField] protected RectTransform background = null; [SerializeField] private RectTransform handle = null; private RectTransform baseRect = null; private Canvas canvas; private Camera cam; private Vector2 input = Vector2.zero; protected virtual void Start() { HandleRange = handleRange; DeadZone = deadZone; baseRect = GetComponent<RectTransform>(); canvas = GetComponentInParent<Canvas>(); if (canvas == null) Debug.LogError("The Joystick is not placed inside a canvas"); Vector2 center = new Vector2(0.5f, 0.5f); background.pivot = center; handle.anchorMin = center; handle.anchorMax = center; handle.pivot = center; handle.anchoredPosition = Vector2.zero; } public virtual void OnPointerDown(PointerEventData eventData) { OnDrag(eventData); } public void OnDrag(PointerEventData eventData) { cam = null; if (canvas.renderMode == RenderMode.ScreenSpaceCamera) cam = canvas.worldCamera; Vector2 position = RectTransformUtility.WorldToScreenPoint(cam, background.position); Vector2 radius = background.sizeDelta / 2; input = (eventData.position - position) / (radius * canvas.scaleFactor); FormatInput(); HandleInput(input.magnitude, input.normalized, radius, cam); handle.anchoredPosition = input * radius * handleRange; } Any help would be appreciated.
I wonder if you could do this: Code (CSharp): input = new Vector2((eventData.position - position) / (radius * canvas.scaleFactor));