Merge branch 'monsterAI'

This commit is contained in:
Benjamin Comeau 2015-11-07 16:31:42 -05:00
commit ab8c736b2d
5 changed files with 135 additions and 23 deletions

View File

@ -97,6 +97,7 @@ GameObject:
- 136: {fileID: 949023943} - 136: {fileID: 949023943}
- 23: {fileID: 949023942} - 23: {fileID: 949023942}
- 114: {fileID: 949023941} - 114: {fileID: 949023941}
- 54: {fileID: 949023946}
m_Layer: 0 m_Layer: 0
m_Name: Monster m_Name: Monster
m_TagString: Untagged m_TagString: Untagged
@ -115,10 +116,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 10ca748d7d0094f16b50525c5401d788, type: 3} m_Script: {fileID: 11500000, guid: 10ca748d7d0094f16b50525c5401d788, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
player: {fileID: 0} player: {fileID: 1900049395}
deadlyDistance: 0 deadlyDistance: 1
rotationDamping: 0 rotationDamping: 2
moveSpeed: 0 moveSpeed: .5
distance: 0
--- !u!23 &949023942 --- !u!23 &949023942
MeshRenderer: MeshRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -170,12 +172,27 @@ Transform:
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 949023940} m_GameObject: {fileID: 949023940}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 1, z: 4.71000004}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: .200000003, y: .200000003, z: .200000003}
m_Children: m_Children:
- {fileID: 1632708745} - {fileID: 1632708745}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 3 m_RootOrder: 4
--- !u!54 &949023946
Rigidbody:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 949023940}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: .0500000007
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 12
m_CollisionDetection: 0
--- !u!1 &1335793729 --- !u!1 &1335793729
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -235,7 +252,93 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 3
--- !u!1 &1447592087
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1447592092}
- 33: {fileID: 1447592091}
- 64: {fileID: 1447592090}
- 23: {fileID: 1447592089}
- 65: {fileID: 1447592088}
m_Layer: 0
m_Name: Sol
m_TagString: Floor
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!65 &1447592088
BoxCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1447592087}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: .999999881, z: 6.12323294e-17}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &1447592089
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1447592087}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
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!64 &1447592090
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1447592087}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 0
serializedVersion: 2
m_Convex: 0
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &1447592091
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1447592087}
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1447592092
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1447592087}
m_LocalRotation: {x: .707106829, y: 0, z: 0, w: .707106709}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 40, y: 40, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1 &1632708744 --- !u!1 &1632708744
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -390,11 +493,11 @@ Transform:
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1741083282} m_GameObject: {fileID: 1741083282}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10} m_LocalPosition: {x: 0, y: 2, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 2
--- !u!1 &1792249522 --- !u!1 &1792249522
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -507,12 +610,12 @@ Transform:
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1900049395} m_GameObject: {fileID: 1900049395}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: .545000017, z: -.409999996} m_LocalPosition: {x: 0, y: 1, z: -.409999996}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 1792249527} - {fileID: 1792249527}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 1
--- !u!82 &1900049397 --- !u!82 &1900049397
AudioSource: AudioSource:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2c1843c7ef59c4177a8d1c75cf7f8399
timeCreated: 1446925711
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: e529ea3a225c2c8468d2027498d3cd74 guid: 4bcce75dab8f540b797340354c772d8b
timeCreated: 1446927748 timeCreated: 1446927249
licenseType: Free licenseType: Free
MonoImporter: MonoImporter:
serializedVersion: 2 serializedVersion: 2

View File

@ -9,6 +9,9 @@ public class monsterAI : MonoBehaviour
public float rotationDamping; // Lower rotation damping = slower rotation public float rotationDamping; // Lower rotation damping = slower rotation
public float moveSpeed; public float moveSpeed;
public float distance;
// Use this for initialization // Use this for initialization
void Start () void Start ()
{ {
@ -31,16 +34,18 @@ public class monsterAI : MonoBehaviour
// Check is the current distance is deadly for the target // Check is the current distance is deadly for the target
bool IsAtDeadlyDistance () bool IsAtDeadlyDistance ()
{ {
return (deadlyDistance <= Vector3.Distance (target.position, transform.position)); return (Vector3.Distance (target.position, transform.position) <= deadlyDistance);
} }
// Look toward target // Look toward target
void LookAtTarget () void LookAtTarget ()
{ {
//Quaternion rotation = Quaternion.LookRotation (target.rotation - transform.rotation); Vector3 relativePos = target.position - transform.position;
//transform.rotation = Quaternion.Slerp (transform.rotation, rotation, Time.deltaTime * rotationDamping); 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. // Follow player from a certain initial distance at a certain speed.
void MoveTowardTarget () void MoveTowardTarget ()
{ {

View File

@ -163,10 +163,8 @@ PlayerSettings:
m_BuildTargetIcons: m_BuildTargetIcons:
- m_BuildTarget: - m_BuildTarget:
m_Icons: m_Icons:
- serializedVersion: 2 - m_Icon: {fileID: 0}
m_Icon: {fileID: 0} m_Size: 0
m_Width: 128
m_Height: 128
m_BuildTargetBatching: [] m_BuildTargetBatching: []
m_BuildTargetGraphicsAPIs: [] m_BuildTargetGraphicsAPIs: []
webPlayerTemplate: APPLICATION:Default webPlayerTemplate: APPLICATION:Default
@ -260,8 +258,6 @@ PlayerSettings:
ps4pnGameCustomData: 1 ps4pnGameCustomData: 1
playerPrefsSupport: 0 playerPrefsSupport: 0
ps4ReprojectionSupport: 0 ps4ReprojectionSupport: 0
ps4UseAudio3dBackend: 0
ps4Audio3dVirtualSpeakerCount: 14
ps4attribUserManagement: 0 ps4attribUserManagement: 0
ps4attribMoveSupport: 0 ps4attribMoveSupport: 0
ps4attrib3DSupport: 0 ps4attrib3DSupport: 0