From a96bffe72a81929f3d1d03a4cf4f44164bd75a60 Mon Sep 17 00:00:00 2001 From: CoryAlanDavis Date: Fri, 29 Jan 2016 23:36:26 -0500 Subject: [PATCH] finished basic wander with the cube. may need to edit once we have actual sprites.. --- Assets/AIScripts/wander.cs | 53 ++++++++++++++++++++++++++ Assets/AIScripts/wander.cs.meta | 12 ++++++ Assets/AITestMap.unity | Bin 0 -> 20108 bytes Assets/AITestMap.unity.meta | 8 ++++ Assets/Dusty Char.meta | 9 +++++ ProjectSettings/ProjectSettings.asset | Bin 38397 -> 38397 bytes ProjectSettings/TagManager.asset | Bin 4308 -> 4316 bytes 7 files changed, 82 insertions(+) create mode 100644 Assets/AIScripts/wander.cs create mode 100644 Assets/AIScripts/wander.cs.meta create mode 100644 Assets/AITestMap.unity create mode 100644 Assets/AITestMap.unity.meta create mode 100644 Assets/Dusty Char.meta diff --git a/Assets/AIScripts/wander.cs b/Assets/AIScripts/wander.cs new file mode 100644 index 0000000..3052d32 --- /dev/null +++ b/Assets/AIScripts/wander.cs @@ -0,0 +1,53 @@ +using UnityEngine; +using System.Collections; + +public class FlyingAI : MonoBehaviour { + + + + public LayerMask enemyMask; + public float speed = 1; + Rigidbody2D myBody; + Transform myTrans; + float myWidth, myHeight; + + // Use this for initialization + void Start() + { + myTrans = this.transform; + myBody = this.GetComponent(); + SpriteRenderer mySprite = this.GetComponent(); + myWidth = mySprite.bounds.extents.x; + myHeight = mySprite.bounds.extents.y; + } + + + // Update is called once per frame + void FixedUpdate () + { + + //check to see if there's ground in front of us before moving forward + Vector2 lineCastPos = myTrans.position.toVector2() - myTrans.right.toVector2() * myWidth + Vector2.up * myHeight; + lineCastPos.y = lineCastPos.y - (myHeight * 1.2f); + Debug.DrawLine(lineCastPos, lineCastPos + Vector2.down); + bool isGrounded = Physics2D.Linecast(lineCastPos, lineCastPos + Vector2.down, enemyMask); + Debug.DrawLine(lineCastPos, lineCastPos - myTrans.right.toVector2() * 0.05f); + bool isBlocked = Physics2D.Linecast(lineCastPos, lineCastPos - myTrans.right.toVector2() * 0.05f, enemyMask); + + //if no ground turn around + if(!isGrounded || isBlocked) + { + Vector3 currentRot = myTrans.eulerAngles; + currentRot.y += 180; + myTrans.eulerAngles = currentRot; + } + + + + //always move forward + Vector2 myVel = myBody.velocity; + myVel.x = -myTrans.right.x * speed; + myBody.velocity = myVel; + } + +} diff --git a/Assets/AIScripts/wander.cs.meta b/Assets/AIScripts/wander.cs.meta new file mode 100644 index 0000000..3ba600e --- /dev/null +++ b/Assets/AIScripts/wander.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fdfeca06308042847a6fb2cd3d736f58 +timeCreated: 1454115530 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/AITestMap.unity b/Assets/AITestMap.unity new file mode 100644 index 0000000000000000000000000000000000000000..bf00ffa9dd8a3ceb177e2edcff9a50e6e4c48d0b GIT binary patch literal 20108 zcmeHP4Uk<$mF|}W2>8d}qN2nXh!6;n5D(W>9((Po97}>F37qv%%+0 zsL%IpN}qA>nd2G{cs_^4=;M42kKu7XM>O$_I}dzzc|PnTKaD&`#_%|wqndce?Sq_` zgAYge3gk>)$HsZM1USdVG21+hpx+<+eqRNgDLoIb7EJMYzgWE{pS9qBJNR(^k0#y_ z`ph|)PiEp=*G!K1T$$%L;2FwuEOE(m-A2&vKxX~8CZ2KRf3D|$Jn;sfnUmoEC&Y8a zll-}!)A4_;$LFB+BJ{Z!b;|QPWG*!4f%CT9Dp5Z%hh63Ugbu&tuB_r?oJeXgW3oRVL2QfUl&w&0%|YTs;)W~h6ONn?h6YJ z|Kg>uUi`V|o@=k{xbXN#sd7bRiggFN{Qs=tk6|h~#Z(2%mZ^AR30o?jT*8)$&vkEt z%2GwBW>j%Cm3g94Hvu;lH+&K3k3!#6d#bqNhb2s%DsFgM#T8dqavtc&pM5iB@V~g~ zQ^j3F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23p>l0UfB7Ca^Se=^t+66UKX7oPdjt5+)Cni+u(Qa tBX-=abKCn*-2okG*-LyMXgxP`$@=+y(Tlh|@o`NZ!R++H_{H_&zX6LQj7I^MjIucOa%Zl-Uf33 delta 14 Wcmeynn(6OqrU?>^h8rcHOa%Zl*#>d| diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index ad3b22fcca75acf8ce99306a741495c9b82594f2..e1dad5b498c7708ba1127eead77ef770aac257b6 100644 GIT binary patch delta 42 ycmcbjct??gfr0541B1YwjT|4C81HQU$&}2?$;!aM;F_13TRB;fIezjU0SN#h!wnJu delta 32 ocmcbkctw$efr0541B1YojT|4C7_V&p$&}1HS(-Uv@(}?E0JTF42><{9