Skip to content

Commit

Permalink
Fixed the StarScript again
Browse files Browse the repository at this point in the history
Wasn't fully working last time.
  • Loading branch information
storm20200 committed Jun 30, 2014
1 parent 189a880 commit d8d3e5d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
18 changes: 16 additions & 2 deletions Assets/Environment/Scripts/StarScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,33 @@ public class StarScript : MonoBehaviour

void OnTriggerStay(Collider other)
{
switch (other.attachedRigidbody.gameObject.layer)
if (other.attachedRigidbody && other.attachedRigidbody.gameObject)
{
switch (other.attachedRigidbody.gameObject.layer)
{
case Layers.capital:
case Layers.enemy:
case Layers.asteroid:
m_damageDelay += Time.deltaTime;
if(m_damageDelay >= m_tickTime)
{
other.gameObject.GetComponent<HealthScript>().DamageMobHullDirectly(m_damagePerTick);
HealthScript script = other.attachedRigidbody.gameObject.GetComponent<HealthScript>();

if (script)
{
script.DamageMobHullDirectly (m_damagePerTick);
}

else
{
Debug.LogError ("Unable to find HealthScript on " + other.attachedRigidbody.name);
}

m_damageDelay = 0.0f;
}

break;
}
}
}
}
7 changes: 5 additions & 2 deletions Assets/Mob Scripts/Scripts/HealthScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,11 @@ void OnMobDies (GameObject killer, GameObject hitter = null)
}
else if(this.tag == "Asteroid")
{
//If it's an asteroid, tell it to split
this.GetComponent<AsteroidScript>().SplitAsteroid(hitter.transform);
Transform hit = hitter ? hitter.transform : transform;

//If it's an asteroid, tell it to split

this.GetComponent<AsteroidScript>().SplitAsteroid(hit);
}
}
[RPC]
Expand Down

0 comments on commit d8d3e5d

Please sign in to comment.