Bug Fix Invaild Reference on Destroy
This commit is contained in:
parent
d48ac4da85
commit
bf8ed223f8
@ -1,7 +1,6 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.AddressableAssets;
|
|
||||||
|
|
||||||
[RequireComponent(typeof(Rigidbody2D))]
|
[RequireComponent(typeof(Rigidbody2D))]
|
||||||
public class AlliedReturn : Physics2DObject
|
public class AlliedReturn : Physics2DObject
|
||||||
@ -11,21 +10,12 @@ public class AlliedReturn : Physics2DObject
|
|||||||
public float normalSpeed = 5f;
|
public float normalSpeed = 5f;
|
||||||
[Tooltip("The amount of speed in which the boat moves away from the castle")]
|
[Tooltip("The amount of speed in which the boat moves away from the castle")]
|
||||||
public float returnSpeed = 5f;
|
public float returnSpeed = 5f;
|
||||||
[Header("Dropped Object")]
|
|
||||||
public GameObject droppedObject;
|
|
||||||
[Header("Death Effect When Shot")]
|
[Header("Death Effect When Shot")]
|
||||||
public GameObject deathEffect;
|
public GameObject deathEffect;
|
||||||
//[Header("Has Droppable Object")]
|
//[Header("Has Droppable Object")]
|
||||||
private bool hasDroppableObject = false;
|
|
||||||
private bool isReturning = false;
|
private bool isReturning = false;
|
||||||
private Vector2 movement = new Vector2(0f, 0f);
|
private Vector2 movement = new Vector2(0f, 0f);
|
||||||
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
@ -48,13 +38,13 @@ public class AlliedReturn : Physics2DObject
|
|||||||
if (playerTag == "Bullet")
|
if (playerTag == "Bullet")
|
||||||
{
|
{
|
||||||
DestroyShip();
|
DestroyShip();
|
||||||
HealthSystemAttribute healthScript = GameObject.Find("CollisionDetector").gameObject.GetComponent<HealthSystemAttribute>();
|
// HealthSystemAttribute healthScript = GameObject.Find("CollisionDetector").gameObject.GetComponent<HealthSystemAttribute>();
|
||||||
if (healthScript != null)
|
// if (healthScript != null)
|
||||||
{
|
// {
|
||||||
// subtract health from the player
|
// // subtract health from the player
|
||||||
healthScript.ModifyHealth(-1);
|
// healthScript.ModifyHealth(-1);
|
||||||
}
|
// }
|
||||||
Destroy(gameObject);
|
// Destroy(gameObject);
|
||||||
}
|
}
|
||||||
else if (playerTag == "Finish" && isReturning)
|
else if (playerTag == "Finish" && isReturning)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user