UPF/Assets/Game/Scripts/Minigame/Solo/SpaceshipBot.cs
2022-12-01 22:41:35 +05:30

33 lines
804 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class SpaceshipBot : MonoBehaviour
{
[SerializeField]private float movingSpeed;
[SerializeField]private float TurningSmoothness;
[SerializeField]private Transform body;
public UnityEvent OnDie;
void FixedUpdate()
{
// body.Translate(body.up * movingSpeed);
body.Translate(new Vector3(0, movingSpeed), body);
}
public void Die(){
OnDie.Invoke();
Destroy(gameObject);
}
public void TrailCollided(Collider2D hit){
// Debug.Log($"I got hit with this : {hit.name}");
if(hit.GetComponent<SpaceshipControllerSolo>()!=null){
hit.GetComponent<SpaceshipControllerSolo>().Die();
}
}
}