mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-16 14:09:00 +07:00
more functions for IsoPhysics
This commit is contained in:
@@ -4,14 +4,16 @@ using System.Collections;
|
||||
|
||||
namespace IsoTools.Examples.Kenney {
|
||||
public class AlienDestroyer : MonoBehaviour {
|
||||
static IsoRaycastHit[] _raycastBuffer = new IsoRaycastHit[16];
|
||||
|
||||
void Update () {
|
||||
var iso_world = IsoWorld.Instance;
|
||||
if ( iso_world && Input.GetMouseButtonDown(0) ) {
|
||||
var iso_mouse_pos = iso_world.MouseIsoPosition();
|
||||
var ray_from_iso_camera = iso_world.RayFromIsoCameraToIsoPoint(iso_mouse_pos);
|
||||
var hits = IsoPhysics.RaycastAll(ray_from_iso_camera);
|
||||
for ( var i = 0; i < hits.Length; ++i ) {
|
||||
var alien_go = hits[i].collider.gameObject;
|
||||
var hit_count = IsoPhysics.RaycastNonAlloc(ray_from_iso_camera, _raycastBuffer);
|
||||
for ( var i = 0; i < hit_count; ++i ) {
|
||||
var alien_go = _raycastBuffer[i].collider.gameObject;
|
||||
if ( alien_go.GetComponent<AlienBallController>() ) {
|
||||
Destroy(alien_go);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user