N
N
NitroFuNyx2020-07-12 23:29:30
Unity
NitroFuNyx, 2020-07-12 23:29:30

Click error?

I try new options for myself to control the object with the mouse.
!!! - Marked a place with an error.
There is this code

if (Input.touchCount > 0||Input.GetMouseButtonDown(0))
        {

      !!!      Swipe();

        }

    }
    private void Swipe()
    {

    !!!    Vector2 delta = Input.GetTouch(0).deltaPosition;
        if (Mathf.Abs(delta.x) > Mathf.Abs(delta.y))
        {
            Vector3 position = transform.position;
            position.x += 1.5f * delta.x;
            transform.position = position;

        }


The error itself is: ArgumentException: Index out of bounds.
UnityEngine.Input.GetTouch (System.Int32 index) (at <2db13ba0d52343228aa9892c408fb49a>:0)
PlayerControl.Swipe () (at Assets/Scripts/PlayerControl.cs:60)
PlayerControl.FixedUpdate () (at Assets/Scripts/PlayerControl.cs :52)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2020-07-12
@GavriKos

Well, you don't have any. In a condition of a call OR. Mouse button pressed != touch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question