Boss Hurts PLayer
This commit is contained in:
29
Assets/Scripts/JumpHitbox.cs
Normal file
29
Assets/Scripts/JumpHitbox.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class JumpHitbox : MonoBehaviour
|
||||
{
|
||||
public PlayerMovement playerMovement;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
Debug.Log("Hit Player");
|
||||
playerMovement.HP -= 1;
|
||||
}
|
||||
else{
|
||||
Debug.Log("Failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/JumpHitbox.cs.meta
Normal file
2
Assets/Scripts/JumpHitbox.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba495adcc9de84e148094bc4f9073dfa
|
||||
29
Assets/Scripts/LungeHitbox.cs
Normal file
29
Assets/Scripts/LungeHitbox.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class LungeHitbox : MonoBehaviour
|
||||
{
|
||||
public PlayerMovement playerMovement;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
Debug.Log("Hit Player");
|
||||
playerMovement.HP -= 1.5f;
|
||||
}
|
||||
else{
|
||||
Debug.Log("Failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/LungeHitbox.cs.meta
Normal file
2
Assets/Scripts/LungeHitbox.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 982fdb439fe8344d68124ca1628747ae
|
||||
@@ -12,6 +12,9 @@ public class SteampunkBoss : MonoBehaviour
|
||||
|
||||
public GameObject JumpHitbox;
|
||||
|
||||
public GameObject LungeHitbox;
|
||||
public float lungeBackup;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
@@ -23,6 +26,7 @@ public class SteampunkBoss : MonoBehaviour
|
||||
{
|
||||
if (stallTimer <= 0)
|
||||
{
|
||||
transform.LookAt(Player.transform);
|
||||
randomNumber = Random.Range(1, 6);
|
||||
setTimer = false;
|
||||
}
|
||||
@@ -113,13 +117,24 @@ public class SteampunkBoss : MonoBehaviour
|
||||
TargetPosition = Player.transform.position;
|
||||
setposition = true;
|
||||
}
|
||||
transform.position = Vector3.MoveTowards(transform.position, TargetPosition, 30 * Time.deltaTime);
|
||||
if (lungeBackup > 0)
|
||||
{
|
||||
transform.position = Vector3.MoveTowards(transform.position, TargetPosition, -10 * Time.deltaTime);
|
||||
lungeBackup -= Time.deltaTime;
|
||||
}
|
||||
if (lungeBackup <= 0)
|
||||
{
|
||||
LungeHitbox.SetActive(true);
|
||||
transform.position = Vector3.MoveTowards(transform.position, TargetPosition, 30 * Time.deltaTime);
|
||||
}
|
||||
if (transform.position == TargetPosition)
|
||||
{
|
||||
LungeHitbox.SetActive(false);
|
||||
stallTimer -= Time.deltaTime;
|
||||
}
|
||||
if (stallTimer <= 0)
|
||||
{
|
||||
lungeBackup = 1;
|
||||
setposition = false;
|
||||
}
|
||||
}
|
||||
@@ -148,9 +163,13 @@ public class SteampunkBoss : MonoBehaviour
|
||||
|
||||
public void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (randomNumber == 1)
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
Debug.Log("Hit Player");
|
||||
playerMovement.HP -= 1;
|
||||
}
|
||||
else{
|
||||
Debug.Log("Failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user