Worked on flying ai stuff
This commit is contained in:
parent
3d5d94f897
commit
d44538d879
Binary file not shown.
9
Assets/GUI.meta
Normal file
9
Assets/GUI.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8bd620c56d8a7d429cd41f9866067af
|
||||
folderAsset: yes
|
||||
timeCreated: 1454180533
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
15
Assets/GUI/GUI.cs
Normal file
15
Assets/GUI/GUI.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class GUI : MonoBehaviour {
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
}
|
12
Assets/GUI/GUI.cs.meta
Normal file
12
Assets/GUI/GUI.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 648f4d518e7553e43bfc19b27ce55c9b
|
||||
timeCreated: 1454180639
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -11,8 +11,10 @@ public class hover : MonoBehaviour
|
||||
float distanceFlown;
|
||||
Rigidbody2D myBody;
|
||||
Transform myTrans;
|
||||
BoxCollider2D hitBox;
|
||||
float myWidth, myHeight;
|
||||
float lastPos;
|
||||
bool goingUp = false;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
@ -20,6 +22,7 @@ public class hover : MonoBehaviour
|
||||
{
|
||||
myTrans = this.transform;
|
||||
myBody = this.GetComponent<Rigidbody2D>();
|
||||
hitBox = this.GetComponent<BoxCollider2D>();
|
||||
SpriteRenderer mySprite = this.GetComponent<SpriteRenderer>();
|
||||
myWidth = mySprite.bounds.extents.x;
|
||||
myHeight = mySprite.bounds.extents.y;
|
||||
@ -27,7 +30,8 @@ public class hover : MonoBehaviour
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
Vector2 lineCastPos;
|
||||
@ -35,14 +39,26 @@ public class hover : MonoBehaviour
|
||||
if (flyPattern == false)
|
||||
{
|
||||
lineCastPos = myTrans.position.toVector2() - myTrans.right.toVector2() * myWidth + Vector2.up * myHeight;
|
||||
|
||||
lineCastPos.y = lineCastPos.y - (myHeight * 1.2f);
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
lineCastPos = myTrans.position.toVector2() - myTrans.up.toVector2() * myWidth + Vector2.right * myHeight;
|
||||
lineCastPos.x -= myWidth;
|
||||
|
||||
if (goingUp)
|
||||
lineCastPos = myTrans.position.toVector2() + myTrans.up.toVector2() * myWidth - Vector2.up * myHeight;
|
||||
|
||||
else
|
||||
{
|
||||
lineCastPos = myTrans.position.toVector2() - myTrans.up.toVector2() * myWidth + Vector2.right * myHeight;
|
||||
lineCastPos.x -= myWidth;
|
||||
lineCastPos.y += myHeight;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -57,22 +73,19 @@ public class hover : MonoBehaviour
|
||||
{
|
||||
Vector3 currentRot = myTrans.eulerAngles;
|
||||
currentRot.y += 180;
|
||||
print(currentRot.x);
|
||||
myTrans.eulerAngles = currentRot;
|
||||
distanceFlown = 0;
|
||||
print("did it");
|
||||
}
|
||||
|
||||
//if hit wall on y-axis ground turn around
|
||||
else if((isBlockedY && flyPattern == true) || (distanceFlown > maxFlightDistance && maxFlightDistance != 0 && flyPattern == true))
|
||||
{
|
||||
Vector3 currentRot = myTrans.eulerAngles;
|
||||
currentRot.x += 180;
|
||||
print(currentRot.x);
|
||||
myTrans.eulerAngles = currentRot;
|
||||
print(myTrans.eulerAngles);
|
||||
//Vector3 currentRot = myTrans.eulerAngles;
|
||||
//currentRot.x += 180;
|
||||
//myTrans.eulerAngles = currentRot;
|
||||
distanceFlown = 0;
|
||||
print("did it");
|
||||
speed = -speed;
|
||||
goingUp = !goingUp;
|
||||
}
|
||||
|
||||
|
||||
|
17
Assets/Resources/Scripts/OnCollision.cs
Normal file
17
Assets/Resources/Scripts/OnCollision.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class OnCollision : MonoBehaviour
|
||||
{
|
||||
void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.gameObject.name == "Player")
|
||||
{
|
||||
print("Ow!");
|
||||
// player is damaged
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
12
Assets/Resources/Scripts/OnCollision.cs.meta
Normal file
12
Assets/Resources/Scripts/OnCollision.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aebfdaf00c4660a41be6535ca1611c4d
|
||||
timeCreated: 1454173173
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user