Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Birb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gadig
Birb
Commits
338c1638
Commit
338c1638
authored
Feb 20, 2017
by
Luke A Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'enemyHorizontal' into 'master'
EnemyToggle See merge request
!13
parents
95005fdc
750b38dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
Assets/Scripts/Enemy/ToggleEnemy.cs
Assets/Scripts/Enemy/ToggleEnemy.cs
+30
-0
No files found.
Assets/Scripts/Enemy/ToggleEnemy.cs
0 → 100644
View file @
338c1638
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
ToggleEnemy
:
MonoBehaviour
{
Camera
cam
;
public
List
<
Collider2D
>
enemies
;
List
<
BaseEnemy
>
disabledEnemies
;
// Use this for initialization
void
Start
()
{
cam
=
Camera
.
main
;
}
// Update is called once per frame
void
Update
()
{
//get frustum of camera
Plane
[]
camPlanes
=
GeometryUtility
.
CalculateFrustumPlanes
(
cam
);
for
(
int
i
=
0
;
i
<
enemies
.
Count
;
i
++)
{
//check if enemy is in view of camera and disable if not
if
(!
GeometryUtility
.
TestPlanesAABB
(
camPlanes
,
enemies
[
i
].
bounds
))
{
enemies
[
i
].
gameObject
.
GetComponent
<
BaseEnemy
>().
enabled
=
false
;
enemies
.
Remove
(
enemies
[
i
]);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment