-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
169 additions
and
56 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class BirdScript : MonoBehaviour { | ||
|
||
//public Vector3 destPoint = Vector3.zero; | ||
|
||
public Vector3 direction = Vector3.zero; | ||
public float speed = 0.05f; | ||
|
||
// Use this for initialization | ||
void Start () { | ||
//direction = destPoint - transform.position; | ||
Destroy(gameObject, 90); | ||
} | ||
|
||
// Update is called once per frame | ||
void Update () { | ||
Vector3 movement = speed * direction * Time.deltaTime; | ||
transform.position = transform.position + movement; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class EnvironmentManager : MonoBehaviour { | ||
|
||
public GameObject[] Birds; | ||
public float birdAltitude; | ||
public float birdSpawnTimer; | ||
public float gameDimensions; | ||
|
||
// Use this for initialization | ||
void Start () { | ||
InvokeRepeating("SpawnBirds", 5, birdSpawnTimer); | ||
} | ||
|
||
|
||
void SpawnBirds() | ||
{ | ||
int index = Random.Range(0, Birds.Length - 1); | ||
|
||
Vector3 initialPosition = new Vector3(-gameDimensions, birdAltitude, Random.Range(-gameDimensions, gameDimensions)); | ||
Vector3 finalPosition = new Vector3(gameDimensions, birdAltitude, Random.Range(-gameDimensions, gameDimensions)); | ||
Vector3 direction = finalPosition - initialPosition; | ||
direction = direction.normalized; | ||
float angle = Vector3.SignedAngle(Vector3.left, direction, Vector3.up); | ||
|
||
GameObject bird = Instantiate(Birds[index], initialPosition, Quaternion.Euler(new Vector3(0, angle, 0))); | ||
bird.GetComponent<BirdScript>().direction = direction; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.