Не работает проверка в if при использовании !=, выдаётся такая ошибка :
Assets\Raytrace.cs(30,21): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Не могу понять как её решить.
Мой код:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Raytrace : MonoBehaviour
{
// Update is called once per frame
public Transform Pointer;
public Transform Player;
public Selectable CurrentSel;
void LateUpdate()
{
//height = transform.position + new Vector3(0, 60, 0);
Ray ray = new Ray();
ray.origin = Player.position;
ray.direction = transform.forward;
Debug.DrawRay(transform.position, transform.forward*100f, Color.red);
Debug.Log(transform.position);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
Pointer.position = hit.point;
Debug.Log("Hit!");
Selectable selectable = hit.collider.gameObject.GetComponent<Selectable>();
if (selectable)
{
if(CurrentSel && CurrentSel != selectable)
{
CurrentSel.Deselect;
}
CurrentSel = selectable;
selectable.Select();
}
else
{
if (CurrentSel)
{
CurrentSel.Deselect();
CurrentSel = null;
}
}
}
else
{
if (CurrentSel)
{
CurrentSel.Deselect();
CurrentSel = null;
}
}
}
}