Started on basic AI -Cory
This commit is contained in:
parent
303640821e
commit
10f20dd615
9
Assets/AIScripts.meta
Normal file
9
Assets/AIScripts.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4c44a4c31a986904d81036cf9e73b54e
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1454116885
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
10
Assets/AIScripts/ExtensionMethods.cs
Normal file
10
Assets/AIScripts/ExtensionMethods.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
public static class ExtensionMethods
|
||||||
|
{
|
||||||
|
public static Vector2 toVector2(this Vector3 vec3)
|
||||||
|
{
|
||||||
|
return new Vector2(vec3.x, vec3.y);
|
||||||
|
}
|
||||||
|
}
|
12
Assets/AIScripts/ExtensionMethods.cs.meta
Normal file
12
Assets/AIScripts/ExtensionMethods.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9a2a3bd0eab8bd44a8b62c66b491b74f
|
||||||
|
timeCreated: 1454122812
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
49
Assets/AIScripts/FlyingAI.cs
Normal file
49
Assets/AIScripts/FlyingAI.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
public class FlyingAI : MonoBehaviour {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public LayerMask enemyMask;
|
||||||
|
public float speed = 1;
|
||||||
|
Rigidbody2D myBody;
|
||||||
|
Transform myTrans;
|
||||||
|
float myWidth;
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
myTrans = this.transform;
|
||||||
|
myBody = this.GetComponent<Rigidbody2D>();
|
||||||
|
myWidth = this.GetComponent<SpriteRenderer>().bounds.extents.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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 - myTrans.right * myWidth;
|
||||||
|
Debug.DrawLine(lineCastPos, lineCastPos + Vector2.down);
|
||||||
|
bool isGrounded = Physics2D.Linecast(lineCastPos, lineCastPos + Vector2.down, enemyMask);
|
||||||
|
Debug.DrawLine(lineCastPos, lineCastPos + Vector2.down);
|
||||||
|
//bool isBlocked = Physics2D.Linecast(lineCastPos, lineCastPos - myTrans.right.toVector2(), enemyMask);
|
||||||
|
|
||||||
|
//if no ground turn around
|
||||||
|
if(!isGrounded)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
12
Assets/AIScripts/FlyingAI.cs.meta
Normal file
12
Assets/AIScripts/FlyingAI.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fdfeca06308042847a6fb2cd3d736f58
|
||||||
|
timeCreated: 1454115530
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/Sprites.meta
Normal file
9
Assets/Sprites.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6f492c3af74d41b4297e290ed0fb7af6
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1454116896
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/Sprites/YellowSquare.png
Normal file
BIN
Assets/Sprites/YellowSquare.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 85 KiB |
57
Assets/Sprites/YellowSquare.png.meta
Normal file
57
Assets/Sprites/YellowSquare.png.meta
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5585634540d87484bbc2cc215b12119f
|
||||||
|
timeCreated: 1454117001
|
||||||
|
licenseType: Free
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
linearTexture: 0
|
||||||
|
correctGamma: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 0
|
||||||
|
cubemapConvolution: 0
|
||||||
|
cubemapConvolutionSteps: 7
|
||||||
|
cubemapConvolutionExponent: 1.5
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: -1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -1
|
||||||
|
wrapMode: 1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
rGBM: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
textureType: 8
|
||||||
|
buildTargetSettings: []
|
||||||
|
spriteSheet:
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Reference in New Issue
Block a user