diff --git a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/EnemyController.cs b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/EnemyController.cs index e1f26f3acbe166714e5a71c0c4f9490074c63827..b0faedce22cc83bbab1f9d43cbee8e584643ebe3 100644 --- a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/EnemyController.cs +++ b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/EnemyController.cs @@ -31,6 +31,11 @@ public class EnemyController : MonoBehaviour StartCoroutine(KingDrop()); } + Vector3 RandomPosition() + { + return new Vector3(Random.Range(-25, 25), 0, Random.Range(-25, 25)); + } + IEnumerator KerocoDrop() { Debug.Log("in thread: " + kerocoCount); @@ -43,10 +48,9 @@ public class EnemyController : MonoBehaviour // Get a random position near the player Vector3 randomDirection = Random.insideUnitSphere * 25; randomDirection += PlayerTransform.position; - NavMeshHit hit; // Sample a position on the NavMesh - if (NavMesh.SamplePosition(randomDirection, out hit, 25, NavMesh.AllAreas)) + if (NavMesh.SamplePosition(randomDirection, out NavMeshHit hit, 25, NavMesh.AllAreas)) { Vector3 finalPosition = hit.position; @@ -59,6 +63,9 @@ public class EnemyController : MonoBehaviour newKeroco.GetComponent<CombatBehavior>().health = 50; kerocoCount++; } + + + // else maybe make a default spawn position } yield return new WaitForSeconds(0.1f); } diff --git a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Gun/ShortWeaponController.cs b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Gun/ShortWeaponController.cs index dccde990767daba29f240a09c2b82ffd1b02c58c..b688bb005fe02b5ed8d5430a3ebc89515e990716 100644 --- a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Gun/ShortWeaponController.cs +++ b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Gun/ShortWeaponController.cs @@ -60,7 +60,7 @@ public class ShortWeaponController : MonoBehaviour } else { rayOrigin = transform.position; - checkHit = Physics.Raycast(rayOrigin, transform.forward, out RaycastHit hit, weaponLength, LayerToHit); + checkHit = Physics.Raycast(rayOrigin, -transform.up, out RaycastHit hit, weaponLength, LayerToHit); raycastHit = hit; } diff --git a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Mobs/KerocoBehaviour.cs b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Mobs/KerocoBehaviour.cs index 3cbad1a41e493d75906dcfd446593fa638057e67..d490b4cffd986653746fb830f27b95e6f22c0b9f 100644 --- a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Mobs/KerocoBehaviour.cs +++ b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Mobs/KerocoBehaviour.cs @@ -10,7 +10,7 @@ public class KerocoBehaviour : MonoBehaviour public LayerMask targetLayer; public GameObject MainPlayer; public float attackArea = 10.0f; - public float attackRange = 5.0f; + public float attackRange = 3.0f; public float speed = 3.0f; public string moveAnimation = "IsChasing"; public string attackAnimation = "Attack"; @@ -56,11 +56,12 @@ public class KerocoBehaviour : MonoBehaviour void Chase(Transform target) { - agent.speed = speed; - agent.SetDestination(target.position); float distance = Vector3.Distance(this.transform.position, target.position); + //Debug.Log("distance" + distance + " attackRange" + attackRange); if (distance <= attackRange) { + //Debug.Log("attack!"); + agent.speed = 0; playerAnimator.SetBool(attackAnimation, true); Vector3 lookAt = target.position; lookAt.y = transform.forward.y; @@ -73,6 +74,9 @@ public class KerocoBehaviour : MonoBehaviour } else { + //Debug.Log("kejarrr"); + agent.speed = speed; + agent.SetDestination(target.position); playerAnimator.SetBool(attackAnimation, false); } }