Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Assets/Bullet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ public class Bullet : MonoBehaviour
public float 存活時間 = 1.5f;
float 結束時間;

public GameObject player;

// Start is called before the first frame update
void Start()
{
Expand All @@ -21,4 +19,10 @@ void Update()
if (Time.time >= 結束時間)
Destroy(gameObject);
}
private void OnCollisionEnter(Collision collision)
{
if(!collision.gameObject.CompareTag("主角")){
Destroy(gameObject);
}
}
}
12 changes: 2 additions & 10 deletions Assets/EnemyFollow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,21 @@ void Update()

if (AttackTrue == true){
動畫控制器.SetFloat("Speed",1f);
動畫控制器.SetBool("Attack",false);
}

// Check if the player is within the attack distance
if (distanceToPlayer <= attackDistance)
{
if(AttackTrue == true){
動畫控制器.SetBool("Attack",true);
動畫控制器.SetFloat("Speed",-1f);
}

// Check the attack cooldown before attacking again
if (attackTimer <= 0.0f)
{
// Attack the player

if(AttackTrue == true)
動畫控制器.SetBool("Attack",true);
AttackPlayer();
attackTimer = attackCooldown; // Reset the cooldown
}
}

}

// Update the attack timer
Expand All @@ -72,9 +66,7 @@ void AttackPlayer()
if (playerHealth != null)
{
playerHealth.TakeDamage(attackDamage);

}

}

void OnControllerColliderHit(ControllerColliderHit hit)
Expand Down
7 changes: 3 additions & 4 deletions Assets/Magic shield yellow.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -14635,7 +14635,7 @@ GameObject:
- component: {fileID: -2100425555622468461}
- component: {fileID: -5384173047286783725}
- component: {fileID: -6690546815680768627}
m_Layer: 6
m_Layer: 0
m_Name: Magic shield yellow
m_TagString: Untagged
m_Icon: {fileID: 0}
Expand Down Expand Up @@ -19510,7 +19510,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
"\u5B58\u6D3B\u6642\u9593": 1.5
player: {fileID: 158050, guid: 479d26050afb50244823e542e662566f, type: 3}
--- !u!114 &-5406406704157259278
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -19536,7 +19535,7 @@ SphereCollider:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8353789554248625585}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.2
Expand All @@ -19555,7 +19554,7 @@ Rigidbody:
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 36
m_Constraints: 0
m_CollisionDetection: 0
--- !u!82 &-6690546815680768627
AudioSource:
Expand Down
Loading