fix alien sample

This commit is contained in:
2015-07-16 01:21:42 +06:00
parent 1d2910fb3b
commit 4ab3de12e7
17 changed files with 66 additions and 28 deletions

View File

@@ -4,10 +4,15 @@ using System.Collections;
namespace IsoTools.Examples {
[RequireComponent(typeof(IsoRigidbody))]
public class AlienBallController : MonoBehaviour {
IsoObject _isoObject = null;
IsoRigidbody _isoRigidbody = null;
void Start() {
_isoObject = GetComponent<IsoObject>();
if ( !_isoObject ) {
throw new UnityException("AlienBallController. IsoObject component not found!");
}
_isoRigidbody = GetComponent<IsoRigidbody>();
if ( !_isoRigidbody ) {
throw new UnityException("AlienBallController. IsoRigidbody component not found!");
@@ -15,6 +20,12 @@ namespace IsoTools.Examples {
StartCoroutine("AddRndForce");
}
void Update() {
if ( _isoObject.positionZ < 0.0f ) {
Destroy(gameObject);
}
}
IEnumerator AddRndForce() {
while ( true ) {
var dx = Random.Range(0.0f, 2.0f);