Walls and camera controller

This commit is contained in:
Arlo Filley 2024-11-24 18:01:49 +00:00
parent 2b99cb9579
commit 926262b7ce
3 changed files with 9 additions and 10 deletions

View File

@ -4,15 +4,15 @@ using UnityEngine;
public class CameraController : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
public Transform cam; // Reference to the camera's Transform
public Transform player; // Reference to the player's Transform
public float height = 5f; // Height offset of the camera above the player
// Update is called once per frame
void Update()
{
// Update the camera position to follow the player while maintaining the height
Vector3 newCameraPosition = new Vector3(player.position.x, player.position.y + height, player.position.z);
cam.position = newCameraPosition;
}
}

View File

@ -27,14 +27,13 @@ public class EnemyMovement : MonoBehaviour
[Header("Spawn")]
public float radius = 5f;
public Vector3 center = new Vector3(0f, 0f, 0f);
void Start()
{
float randomAngle = UnityEngine.Random.Range(0f, 2 * Mathf.PI);
// Calculate the point on the perimeter of the circle
Vector3 point = center + new Vector3(Mathf.Cos(randomAngle) * radius, 0.6f, Mathf.Sin(randomAngle) * radius);
Vector3 point = player.position + new Vector3(Mathf.Cos(randomAngle) * radius, 0.6f, Mathf.Sin(randomAngle) * radius);
enemy.position = point;
if (movementType == MovementTypes.ThroughPlayer)
@ -45,7 +44,7 @@ public class EnemyMovement : MonoBehaviour
}
// Update is called once per frame
void Update()
void FixedUpdate()
{
if (movementType == MovementTypes.Line)
{

View File

@ -55,7 +55,7 @@ public class PlayerController : MonoBehaviour
}
}
void Update()
void FixedUpdate()
{
Vector3 moveDirection = GetPlayerDirection().normalized;