Hello again. I would want some help with a script for Direct, being the usual Soldier script. Direct is going to have what I would call “Classes” which is that every enemy and ally have the same scripts with different variable values. If you still don’t understand, see it like Soldier, Wizard and Rogue scripts where each NPC have one of these class scripts and will act similarly to someone with the same script.
I have started all over again because the first set of scripts where messy and near unreadable.
using UnityEngine;
using UnityEngine.AI;
namespace EightDirectionalSpriteSystem
{
public class SoldierActor : MonoBehaviour
{
public enum STATE { Idle, Moving, Ambushing, Attacking, Hurt, Dead };
public STATE currentState = STATE.Idle;
// Status
public int health = 100;
public int armor;
// Rendering
public ActorBillboard actorBillboard;
public ActorAnimation idleAnim, moveAnim, readyAnim, shootAnim, hurtAnim, deathAnim;
public SpriteRenderer rend;
// Components
ActorList listy;
public EyeScript eyes;
Transform myTransform;
// Booleans
public bool aware;
// AI
public NavMeshAgent agent;
public Vector3 locationToGo;
public float accuracy = 0.6f;
void Awake()
{
agent.updateRotation = false;
myTransform = GetComponent<Transform>();
listy = GetComponent<ActorList>();
eyes = GetComponentInChildren<EyeScript>();
}
// Update is called once per frame
void Update()
{
switch(currentState)
{
case STATE.Idle:
agent.isStopped = true;
break;
case STATE.Moving:
agent.isStopped = false;
break;
case STATE.Ambushing:
agent.isStopped = false;
break;
case STATE.Attacking:
agent.isStopped = true;
break;
case STATE.Hurt:
agent.isStopped = true;
break;
}
}
private void LateUpdate()
{
transform.rotation = Quaternion.LookRotation(agent.velocity.normalized);
if (agent.velocity.sqrMagnitude > Mathf.Epsilon)
{
transform.rotation = Quaternion.LookRotation(agent.velocity.normalized);
}
}
public void AmbushEnemy()
{
currentState = STATE.Ambushing;
}
}
}
This is how far I’ve come. ActorList is what links the class scripts together.
The sprite system I use have some slightly difficult to animate technique. It can’t be updated all the time or the sprite will freeze on the first frame. (If you don’t know what sprite system then just ask)
I have plenty more scripts to show (If I must). I really need help please.