mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-15 01:12:05 +07:00
27 lines
727 B
C#
27 lines
727 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
namespace IsoTools.Examples {
|
|
[RequireComponent(typeof(IsoRigidbody))]
|
|
public class AlienBallController : MonoBehaviour {
|
|
|
|
IsoRigidbody _isoRigidbody = null;
|
|
|
|
void Start() {
|
|
_isoRigidbody = GetComponent<IsoRigidbody>();
|
|
if ( !_isoRigidbody ) {
|
|
throw new UnityException("AlienBallController. IsoRigidbody component not found!");
|
|
}
|
|
StartCoroutine("AddRndForce");
|
|
}
|
|
|
|
IEnumerator AddRndForce() {
|
|
while ( true ) {
|
|
var dx = Random.Range(0.0f, 2.0f);
|
|
var dy = Random.Range(0.0f, 2.0f);
|
|
_isoRigidbody.AddForce(new Vector3(dx, dy, 0.0f), ForceMode.Impulse);
|
|
yield return new WaitForSeconds(1);
|
|
}
|
|
}
|
|
}
|
|
} // namespace IsoTools.Examples |