Help me!!! Expected script

Assets\Scripts\SwipePlayer.cs(50,65): error CS1026: ) expected

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SwipePlayer : MonoBehaviour
{

public static event OnSwipeInput SwipeEvent;
public delegate void OnSwipeInput(Vector2 direction);

private Vector2 tapPosition;
private Vector2 swipeDelta;

private float deadzone = 80;
private bool isSwiping;
private bool isMobile;

// Start is called before the first frame update
void Start()
{
isMobile = Application.isMobilePlatform;
}

// Update is called once per frame
void Update()
{
if (isMobile)
{
if (Input.GetMouseButtonDown(0))
{
isSwiping = true;
tapPosition = Input.mousePosition;
}
else if (Input.GetMouseButtonUP(0))
{
ResetSwipe();
}
}
else
{
if (Input.touchCount > 0)
{
if (Input.GetTouch(0).phase == TouchPhase.Began)
{
isSwiping = true;
tapPosition = Input.GetTouch(0).position;
}
else if ((Input.GetTouch(0).phase == TouchPhase.Canseled ||
Input.GetTouch(0).phase == TouchPhase.Ended)
{
ResetSwipe();
}
}
}

CheckSwipe();

}

private void CheckSwipe()
{
swipeDelta = Vector2.zero;

if (isSwiping)
{
if (!isMobile && Input.GetMouseButton(0))
swipeDelta = (Vector2)Input.mousePosition - topPosition;
else if (Input.touchCount > 0)
swipeDelta = Input.touchCount(0).position - tapPosition;
}
if (swipeDelta.magnitude > deadZone)
{
if (SwipeEvent != null)
{
if (Mathf.Ads(swipeDelta.x) > Mathf.Ads(swipeDelta.y))
SwipeEvent(swipeDelta.x > 0 ? Vector2.right : Vector2.left);
else
SwipeEvent(swipeDelta.y > 0 ? Vector2.up : Vector2.down);
}

ResetSwipe();
}
}

private void ResetSwipe()
{
isSwiping = false;

tapPosition = Vector2.zero;
swipeDelta = Vector2.zero;
}
}

https://discussions.unity.com/t/481379

I won’t start counting and may or may not find your problem for you. You know the problematic line. Also, do not duplicate your posts please.

1 Like

…it says you’re missing a “)” on line 50, 65 characters over :slight_smile:

Also, if you don’t use code tags, there’s a good chance your question will be ignored… it’s just too hard for anyone to see which line is #50 without them. See the “Code: <>” button above where you post, then paste the code into that box.

for
example,
<- this is line 3,
immediately identified with code tags
1 Like