Walls and camera controller
This commit is contained in:
parent
2b99cb9579
commit
926262b7ce
@ -4,15 +4,15 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class CameraController : MonoBehaviour
|
public class CameraController : MonoBehaviour
|
||||||
{
|
{
|
||||||
// Start is called before the first frame update
|
public Transform cam; // Reference to the camera's Transform
|
||||||
void Start()
|
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
|
// Update is called once per frame
|
||||||
void Update()
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,14 +27,13 @@ public class EnemyMovement : MonoBehaviour
|
|||||||
|
|
||||||
[Header("Spawn")]
|
[Header("Spawn")]
|
||||||
public float radius = 5f;
|
public float radius = 5f;
|
||||||
public Vector3 center = new Vector3(0f, 0f, 0f);
|
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
float randomAngle = UnityEngine.Random.Range(0f, 2 * Mathf.PI);
|
float randomAngle = UnityEngine.Random.Range(0f, 2 * Mathf.PI);
|
||||||
|
|
||||||
// Calculate the point on the perimeter of the circle
|
// 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;
|
enemy.position = point;
|
||||||
|
|
||||||
if (movementType == MovementTypes.ThroughPlayer)
|
if (movementType == MovementTypes.ThroughPlayer)
|
||||||
@ -45,7 +44,7 @@ public class EnemyMovement : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
if (movementType == MovementTypes.Line)
|
if (movementType == MovementTypes.Line)
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
Vector3 moveDirection = GetPlayerDirection().normalized;
|
Vector3 moveDirection = GetPlayerDirection().normalized;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user