This school project I had to make with my classmates 2 from game artist and a other developer, The objective was to make a 3D twin stick shooter.
Enemy
For the movement I used a rigidbody based movement and the for input the new player input.
using UnityEngine;
using UnityEngine.InputSystem;
[SelectionBase]
public class PlayerMovement : MonoBehaviour
{
private Rigidbody _Rigidbody;
private InputAction _MoveAction;
private PlayerInput _PlayerInput;
[SerializeField] private float _PlayerSpeed;
private void Start()
{
_PlayerInput = GetComponent();
_MoveAction = _PlayerInput.actions.FindAction("Move");
_Rigidbody = GetComponent();
}
private void Update()
{
CalculateMovement();
}
private void CalculateMovement()
{
Vector2 direction = _MoveAction.ReadValue().normalized;
Vector3 movement = new Vector3(direction.x, 0f, direction.y);
_Rigidbody.velocity = movement * _PlayerSpeed;
}
}
As for the picking up the collectibles I use a OnTriggerEnter that gets the
using UnityEngine;
public class CollectibleHandler : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Coin"))
{
GameManager.Instance.GetPointValue(other.GetComponent().GetPoints());
Destroy(other.gameObject);
}
}
}
Enemy
For the enemy movement I use unity's navmesh component. EnemyManager is the way I dictate when the ghost are able to move. How I sat it up was to put the ghosts in Enemies array and then loop through each of them and turn the navmesh agent back on. How I normally would do it is to have a EnemyBrain script that in the awake registers the enemy to the manager but since I had little time I didnt take that approach.