Last active
August 29, 2015 14:22
-
-
Save crilleengvall/6e27628b1b09acc9ac23 to your computer and use it in GitHub Desktop.
How to check if a game object has stopped moving
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class StuckSheepCheck : MonoBehaviour { | |
public GameObject Sheep; | |
public GameObject SheepTwo; | |
private Rigidbody2D SheepRigidbody2D; | |
private Rigidbody2D SheepTwoRigidbody2D; | |
void Start() { | |
this.SheepRigidbody2D = Sheep.GetComponent<Rigidbody2D>(); | |
this.SheepTwoRigidbody2D = SheepTwo.GetComponent<Rigidbody2D>(); | |
} | |
void FixedUpdate () { | |
this.CheckIfSheepIsStuck(); | |
} | |
private void CheckIfSheepIsStuck() { | |
if(this.SheepRigidbody2D.IsSleeping() && this.SheepTwoRigidbody2D.IsSleeping()) { | |
SheepGameEnder.Instance.EndGame(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment