Merge branch 'monsterAI'

This commit is contained in:
Benjamin Comeau 2015-11-07 17:21:06 -05:00
commit a823aaa090
7 changed files with 367 additions and 32 deletions

View File

@ -0,0 +1,139 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: GlassWallMaterial
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON
m_LightmapFlags: 5
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _BumpMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailNormalMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _ParallaxMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _OcclusionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _EmissionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailMask
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _DetailAlbedoMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
data:
first:
name: _SrcBlend
second: 1
data:
first:
name: _DstBlend
second: 10
data:
first:
name: _Cutoff
second: .5
data:
first:
name: _Parallax
second: .0199999996
data:
first:
name: _ZWrite
second: 0
data:
first:
name: _Glossiness
second: 0
data:
first:
name: _BumpScale
second: 1
data:
first:
name: _OcclusionStrength
second: 1
data:
first:
name: _DetailNormalMapScale
second: 1
data:
first:
name: _UVSec
second: 0
data:
first:
name: _Mode
second: 3
data:
first:
name: _Metallic
second: 0
m_Colors:
data:
first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
data:
first:
name: _Color
second: {r: .865999997, g: 1, b: 1, a: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cbd2ba8b0fae54da187ae28b60c8289e
timeCreated: 1446932082
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 89e688205bb8d4257a9ec810efa7061f
folderAsset: yes
timeCreated: 1446934426
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -96,8 +96,9 @@ GameObject:
- 33: {fileID: 949023944}
- 136: {fileID: 949023943}
- 23: {fileID: 949023942}
- 195: {fileID: 949023946}
- 114: {fileID: 949023941}
- 54: {fileID: 949023946}
- 54: {fileID: 949023947}
m_Layer: 0
m_Name: Monster
m_TagString: Untagged
@ -117,10 +118,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
player: {fileID: 1900049395}
deadlyDistance: 1
rotationDamping: 2
moveSpeed: .5
distance: 0
deadlyDistance: 0
rotationDamping: 0
moveSpeed: 0
--- !u!23 &949023942
MeshRenderer:
m_ObjectHideFlags: 0
@ -178,7 +178,27 @@ Transform:
- {fileID: 1632708745}
m_Father: {fileID: 0}
m_RootOrder: 4
--- !u!54 &949023946
--- !u!195 &949023946
NavMeshAgent:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 949023940}
m_Enabled: 1
m_Radius: .5
m_Speed: 2
m_Acceleration: 8
avoidancePriority: 50
m_AngularSpeed: 120
m_StoppingDistance: 1
m_AutoTraverseOffMeshLink: 1
m_AutoBraking: 1
m_AutoRepath: 1
m_Height: 2
m_BaseOffset: 1
m_WalkableMask: 4294967295
m_ObstacleAvoidanceType: 4
--- !u!54 &949023947
Rigidbody:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
@ -191,8 +211,81 @@ Rigidbody:
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 12
m_Constraints: 0
m_CollisionDetection: 0
--- !u!1 &1149994029
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1149994033}
- 33: {fileID: 1149994032}
- 65: {fileID: 1149994031}
- 23: {fileID: 1149994030}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!23 &1149994030
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1149994029}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_Materials:
- {fileID: 2100000, guid: cbd2ba8b0fae54da187ae28b60c8289e, type: 2}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 1
m_ReflectionProbeUsage: 1
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_ImportantGI: 0
m_AutoUVMaxDistance: .5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!65 &1149994031
BoxCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1149994029}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &1149994032
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1149994029}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1149994033
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1149994029}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -2.1400001, y: 1, z: 0}
m_LocalScale: {x: .00999999978, y: 2, z: 4}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
--- !u!1 &1335793729
GameObject:
m_ObjectHideFlags: 0
@ -219,7 +312,7 @@ Light:
serializedVersion: 6
m_Type: 1
m_Color: {r: 1, g: .956862748, b: .839215696, a: 1}
m_Intensity: 1
m_Intensity: 1.37
m_Range: 10
m_SpotAngle: 30
m_CookieSize: 10
@ -798,3 +891,76 @@ MonoBehaviour:
m_FootstepSounds: []
m_JumpSound: {fileID: 0}
m_LandSound: {fileID: 0}
--- !u!1 &1997970884
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1997970888}
- 33: {fileID: 1997970887}
- 65: {fileID: 1997970886}
- 23: {fileID: 1997970885}
m_Layer: 0
m_Name: Cube (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!23 &1997970885
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1997970884}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_Materials:
- {fileID: 2100000, guid: cad7fc84f4314964f87485777e6410c0, type: 2}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 1
m_ReflectionProbeUsage: 1
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_ImportantGI: 0
m_AutoUVMaxDistance: .5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!65 &1997970886
BoxCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1997970884}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &1997970887
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1997970884}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1997970888
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1997970884}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3.83999991, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6

View File

@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!238 &23800000
NavMeshData:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: NavMesh
m_NavMeshTiles:
- m_MeshData: 56414e4410000000ffffffffffffffff00000000070000000e00000007000000000000000c0000000e000000abaa2ac2000080bfabaa2ac2000000003333c340000000000000c040565565c1b0aaaa3d000020c0505515c0b0aaaa3d000020c00000c0bfb0aaaa3db0aa0ac00000c0bfb0aaaa3d0000000000000000b0aaaa3d0000000000000000b0aaaa3d565565c1565565c1b0aaaa3d565565c1565565c1b0aaaa3d000000000000e0c0b0aaaa3d000000005855d5c0b0aaaa3d000080bf5855a5c0b0aaaa3d000080bfa8aa9ac0b0aaaa3d00000000b0aa2ac0b0aaaa3d00000000b0aa2ac0b0aaaa3db0aa0ac00200030004000500000000000000028000800300000000000100000004000000010005000600000000000000030000000000070000000000010000000400000001000200050000000000000000000100020000000000000001000000030000000a000b000c000d0000000000000002800000060000000000010000000400000007000800090000000000000002800000070000000000000001000000030000000a000d00010009000000000004000000070000000000000001000000040000000900010000000700000000000600020000000500000000000100000004000000000000000000000000000200000000000200000000000200000000000400000000000100000000000500000000000200000000000700000000000100000000000800000000000200000000000a00000000000200020003000000050000000100020005000200030000000500000001000200050001000200000015000200030000000500000001000200050001000200000015000200030000000500000001000200050002000300000005000000010002000500aa000600aa0000010c000001f3ffffffaa000600aa0000010c000001fbffffffaa000600fa00d8000c00000104000000aa000600aa0000010c000001fdffffffaa000600aa0000010c00f10001000000aa000600f100f2000c00000106000000d8000600aa0000010c000001f9fffffff2000600aa0000010c000001fdfffffff2000600aa0000010c00f30002000000f7000600aa0000010c00000100000000d8000600f100f2000c000001fdffffffd8000600f100f2000c00fa0005000000e1000600f300f0000c0000010300000000000000000000000000000000000000
- m_MeshData: 56414e441000000000000000ffffffff0000000001000000040000000100000000000000020000000200000000000000000080bfabaa2ac2abaa2a423333c340000000000000c04000000000b0aaaa3d0000000000006841b0aaaa3d0000000000006841b0aaaa3d565565c100000000b0aaaa3d565565c100000100020003000000000002800000000004800000000001000000040000000000000000000000000002000200030001001100030000000100050000000600aa0057000c0000010000000000000000000000000000000000000000
- m_MeshData: 56414e4410000000ffffffff0000000000000000080000001000000008000000000000000e00000010000000abaa2ac2000080bf00000000000000003333c340abaa2a420000c040565565c1b0aaaa3dabaa2a40505515c0b0aaaa3dabaa2a40b0aa2ac0b0aaaa3d56551540b0aa2ac0b0aaaa3d00000000a8aa9ac0b0aaaa3d00000000a8aa9ac0b0aaaa3d5655553f5855a5c0b0aaaa3d5655953f5855d5c0b0aaaa3d5655953f0000e0c0b0aaaa3d5655553f0000e0c0b0aaaa3d00000000565565c1b0aaaa3d00000000565565c1b0aaaa3d0000684100000000b0aaaa3d0000684100000000b0aaaa3d000000000000c0bfb0aaaa3d000000000000c0bfb0aaaa3d5655154003000400050000000000000006800000020000000000000001000000030000000200030005000600000000000000010000000400000000000100000004000000080009000a000000000000000000068005000000000000000100000003000000010002000600070000000000000002000000050007000000010000000500000008000a00000007000000000003000000040000000000000001000000040000000d000e000f000c00000000000680000008000080000000000100000004000000010000000b000c000000000004000000000008000000000001000000040000000c000f0001000000000000000600000007000000000000000100000003000000000000000000000000000100000000000100000000000200000000000300000000000100000000000400000000000300000000000700000000000200000000000900000000000200000000000b00000000000200000000000d0000000000010001000200000015000200030000000500000001000200050001000200000015000300040000000500000001000200050002000300000001000200030000000500000001000200050002000300000005000000010002000500020003000000050000000100020005000100020000001500aa000600000000010c005700f1ffffffaa0006000000f0000c001000f9ffffffaa0006000000d8000c001000fdffffffaa0006000000d6000c00050002000000aa0006000000d8000c00100004000000e10006000000f0000c000e00fdffffffe10006000000f0000c000e0001000000e30006000000f0000c00050000000000aa000600000000010c005700f9ffffffaa000600000000010c005700fdfffffff7000600000000010c00570005000000aa0006000700f2000c00100003000000aa0006000e0000010c005700fdffffffaa000600100000010c00570006000000f20006000e0000010c0057000700000000000000000000000000000000000000
- m_MeshData: 56414e441000000000000000000000000000000001000000040000000100000000000000020000000200000000000000000080bf00000000abaa2a423333c340abaa2a420000c04000000000b0aaaa3d0000684100006841b0aaaa3d0000684100006841b0aaaa3d0000000000000000b0aaaa3d0000000000000100020003000000000000000000068004800000000001000000040000000000000000000000000002000200030001001100030000000100050000000600000057000c0057000000000000000000000000000000000000000000
m_NavMeshParams:
tileSize: 42.6666679
walkableHeight: 2
walkableRadius: .5
walkableClimb: .416666687
cellSize: .166666672
m_Heightmaps: []
m_HeightMeshes: []
m_OffMeshLinks: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3640b58b7a29a41e7b868ac3205e5dc9
timeCreated: 1446934544
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -6,17 +6,17 @@ public class monsterAI : MonoBehaviour
public GameObject player;
private Transform target;
public float deadlyDistance;
public float rotationDamping; // Lower rotation damping = slower rotation
public float moveSpeed;
public float distance;
private NavMeshAgent agent;
// Use this for initialization
void Start ()
{
target = player.transform;
agent = gameObject.GetComponent<NavMeshAgent> ();
agent.SetDestination (target.position);
}
// Update is called once per frame
@ -24,10 +24,9 @@ public class monsterAI : MonoBehaviour
{
if (IsAtDeadlyDistance ()) {
// Kill the player
} else {
LookAtTarget ();
MoveTowardTarget ();
}
agent.SetDestination (target.position);
}
@ -36,20 +35,4 @@ public class monsterAI : MonoBehaviour
{
return (Vector3.Distance (target.position, transform.position) <= deadlyDistance);
}
// Look toward target
void LookAtTarget ()
{
Vector3 relativePos = target.position - transform.position;
Quaternion rotation = Quaternion.LookRotation (relativePos);
transform.rotation = Quaternion.Slerp (transform.rotation, rotation, Time.deltaTime * rotationDamping);
}
// Follow player from a certain initial distance at a certain speed.
void MoveTowardTarget ()
{
transform.Translate (Vector3.forward * moveSpeed * Time.deltaTime);
}
}