Skip to content

Commit

Permalink
Added Bird Interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
HikkusT committed Aug 15, 2017
1 parent d8ca3ad commit cd552a6
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 56 deletions.
16 changes: 15 additions & 1 deletion Assets/prefab/Environment/Bird.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ GameObject:
m_Component:
- component: {fileID: 4566441118619900}
- component: {fileID: 95534507543826482}
- component: {fileID: 114508622589608510}
m_Layer: 0
m_Name: Bird
m_TagString: Untagged
Expand Down Expand Up @@ -212,7 +213,7 @@ Transform:
m_GameObject: {fileID: 1019625292539496}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_LocalScale: {x: 0.13, y: 0.13, z: 0.13}
m_Children:
- {fileID: 4167516548053164}
- {fileID: 4769310045948862}
Expand Down Expand Up @@ -290,6 +291,19 @@ Animator:
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
--- !u!114 &114508622589608510
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1019625292539496}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 85fb1214d3170ef41b958d3941b61865, type: 3}
m_Name:
m_EditorClassIdentifier:
direction: {x: 0, y: 0, z: 0}
speed: 0.7
--- !u!137 &137530927851762424
SkinnedMeshRenderer:
m_ObjectHideFlags: 1
Expand Down
131 changes: 76 additions & 55 deletions Assets/scenes/Main.unity
Original file line number Diff line number Diff line change
Expand Up @@ -390,33 +390,6 @@ Prefab:
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 5308f69fc25c14578b49e1bfc2e6033e, type: 2}
m_IsPrefabParent: 0
--- !u!84 &371081452
RenderTexture:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_Width: 1616
m_Height: 909
m_AntiAliasing: 1
m_DepthFormat: 2
m_ColorFormat: 0
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 0
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
--- !u!1001 &388654348
Prefab:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -952,6 +925,33 @@ GameObject:
m_PrefabParentObject: {fileID: 1918428659857364, guid: da42a4da83762402ab84356f1fafda0e,
type: 2}
m_PrefabInternal: {fileID: 123591628}
--- !u!84 &1272842076
RenderTexture:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_Width: 1616
m_Height: 909
m_AntiAliasing: 1
m_DepthFormat: 2
m_ColorFormat: 0
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 0
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
--- !u!1001 &1327058667
Prefab:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1110,6 +1110,27 @@ Prefab:
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 74f4d1f54da024845bcab1fd08899c37, type: 2}
m_IsPrefabParent: 0
--- !u!1 &1327736763 stripped
GameObject:
m_PrefabParentObject: {fileID: 1314678458617260, guid: a0ae3f0160a394622b2556300039986c,
type: 2}
m_PrefabInternal: {fileID: 572187896}
--- !u!114 &1327736777
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1327736763}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0a7a28846c0461040b959729999a449e, type: 3}
m_Name:
m_EditorClassIdentifier:
Birds:
- {fileID: 1019625292539496, guid: 560bf1c4085790b43bbd604dd64b086a, type: 2}
birdAltitude: 7
birdSpawnTimer: 20
gameDimensions: 25
--- !u!1 &1344477235 stripped
GameObject:
m_PrefabParentObject: {fileID: 1831576709337820, guid: 74f4d1f54da024845bcab1fd08899c37,
Expand All @@ -1120,33 +1141,6 @@ Transform:
m_PrefabParentObject: {fileID: 4570669095973516, guid: 2f16d96d8e95f4ee893d3f69273b7e64,
type: 2}
m_PrefabInternal: {fileID: 182574045}
--- !u!84 &1456201070
RenderTexture:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_Width: 640
m_Height: 480
m_AntiAliasing: 1
m_DepthFormat: 2
m_ColorFormat: 0
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 0
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
--- !u!114 &1573586643 stripped
MonoBehaviour:
m_PrefabParentObject: {fileID: 114812045155361606, guid: a0ae3f0160a394622b2556300039986c,
Expand Down Expand Up @@ -1196,7 +1190,7 @@ Prefab:
type: 2}
propertyPath: m_TargetTexture
value:
objectReference: {fileID: 1456201070}
objectReference: {fileID: 1698277658}
- target: {fileID: 114647825517582250, guid: 6849b8a20f320f04dabdfd7ed9070271,
type: 2}
propertyPath: m_Enabled
Expand Down Expand Up @@ -1235,6 +1229,33 @@ Prefab:
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 6849b8a20f320f04dabdfd7ed9070271, type: 2}
m_IsPrefabParent: 0
--- !u!84 &1698277658
RenderTexture:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_Width: 964
m_Height: 542
m_AntiAliasing: 1
m_DepthFormat: 2
m_ColorFormat: 0
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 0
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
--- !u!1001 &1710198126
Prefab:
m_ObjectHideFlags: 0
Expand Down
23 changes: 23 additions & 0 deletions Assets/scripts/BirdScript.cs
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;
}
}
12 changes: 12 additions & 0 deletions Assets/scripts/BirdScript.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions Assets/scripts/EnvironmentManager.cs
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;
}
}
12 changes: 12 additions & 0 deletions Assets/scripts/EnvironmentManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cd552a6

Please sign in to comment.