Added enemy models

This commit is contained in:
Pasha Bibko
2026-01-22 11:37:51 +00:00
parent 06169f648f
commit ff0ab96c4d
38 changed files with 2267 additions and 89 deletions

View File

@@ -1,4 +1,6 @@
using UnityEngine;
using System.Collections;
using UnityEngine;
using Random = UnityEngine.Random;
namespace InterfaceOff.WorldScene
{
@@ -6,9 +8,53 @@ namespace InterfaceOff.WorldScene
{
[SerializeField] private PlayerController Player;
[SerializeField] private int DeathIndex = 500;
[SerializeField] private GameObject Renderer;
[SerializeField] private Rigidbody Body;
[SerializeField] private GameObject RendererObject;
private void Update() =>
Renderer.SetActive(DeathIndex > Player.FrameIndex);
private Quaternion StartRotation;
private Vector3 StartPosition;
private bool WasAliveLastFrame;
private bool Alive = true;
private void Start()
{
StartPosition = transform.position;
StartRotation = transform.rotation;
Body.Sleep();
}
private void Update()
{
/* Updates the death state */
WasAliveLastFrame = Alive;
Alive = DeathIndex >= Player.FrameIndex;
/* Checks if it just died */
if (!Alive && WasAliveLastFrame)
{
Body.WakeUp();
Body.AddForce(Random.insideUnitSphere * 250);
StartCoroutine(routine: Suicide());
}
if (Alive)
{
transform.position = StartPosition;
transform.rotation = StartRotation;
Body.velocity = Vector3.zero;
RendererObject.SetActive(true);
Body.Sleep();
}
}
private IEnumerator Suicide()
{
yield return new WaitForSeconds(1f);
RendererObject.SetActive(false);
}
}
}