Здравствуйте, имеется код:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BigGun : MonoBehaviour {
public Transform playerPos;
public Transform shootPoint;
public GameObject bullet;
private Animator anim;
public float timer;
private float newTimer;
private Vector2 spacing;
public float spacingValue;
void Start()
{
anim = GetComponent<Animator>();
newTimer = timer;
}
void Update () {
Vector2 spacing = playerPos.position - transform.position;
newTimer -= Time.deltaTime;
if (spacing.x < spacingValue && newTimer == 0) //Здесь не работает почему то
{
Instantiate(bullet, shootPoint.position, shootPoint.rotation);
anim.SetTrigger("Detected");
newTimer = timer;
}
}
Проблема с условием.