using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody2D))]
public class Spider : MonoBehaviour, IDamagable
{
[SerializeField] private float _speed;
[SerializeField] private GameObject _player;
private Rigidbody2D _ridigbody2D;
private HealthSystem _healthSystem;
private void Awake()
{
_healthSystem = new HealthSystem(1);
}
private void Start()
{
_ridigbody2D = GetComponent<Rigidbody2D>();
_player = GameObject.FindGameObjectWithTag("Player");
}
private void Update()
{
Move();
}
private void Move()
{
float dirToMove = Mathf.Sign(transform.position.x - _player.transform.position.x);
_ridigbody2D.velocity = new Vector2(dirToMove * _speed, _ridigbody2D.velocity.y);
}
public void DealDamage(int damageAmount)
{
}
}
Ничего такого, но при запуске тупо в 0 виснет