Skip to content

Commit

Permalink
make the cat move randomly
Browse files Browse the repository at this point in the history
  • Loading branch information
thewithz committed Feb 13, 2020
1 parent ff0f9d5 commit d3f0187
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 17 deletions.
55 changes: 41 additions & 14 deletions OdysseyNow/Assets/Scenes/Card4.unity
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ NavMeshAgent:
m_Enabled: 1
m_AgentTypeID: -334000983
m_Radius: 0.21
m_Speed: 3.5
m_Speed: 1
m_Acceleration: 300
avoidancePriority: 50
m_AngularSpeed: 3000
Expand All @@ -340,7 +340,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b6aa0652006149c41b9fca129b5a01d5, type: 3}
m_Name:
m_EditorClassIdentifier:
target: {fileID: 135568843}
target: {fileID: 431468004}
stop: 0
--- !u!1 &24524509
GameObject:
Expand Down Expand Up @@ -636,12 +636,6 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 123296594}
m_Mesh: {fileID: 4300002, guid: 945d428a49e83c946b2e03b26fc0ab17, type: 3}
--- !u!1 &135568843 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 5755280646380965434, guid: 6335a3f5d84d6421eb04d6f447784f85,
type: 3}
m_PrefabInstance: {fileID: 5755280646347381175}
m_PrefabAsset: {fileID: 0}
--- !u!1 &140990046
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1532,7 +1526,7 @@ Transform:
- {fileID: 901483186}
- {fileID: 1925552866}
m_Father: {fileID: 1405386638}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &426222353
GameObject:
Expand Down Expand Up @@ -1613,6 +1607,36 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 426222353}
m_Mesh: {fileID: 4300008, guid: 945d428a49e83c946b2e03b26fc0ab17, type: 3}
--- !u!1 &431468003
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 431468004}
m_Layer: 0
m_Name: Cheese
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &431468004
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 431468003}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 4.65, y: -3.55, z: 0.7}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1405386638}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &433494987
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1957,7 +1981,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1405386638}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!114 &602582429
MonoBehaviour:
Expand Down Expand Up @@ -4863,6 +4887,7 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 431468004}
- {fileID: 354303000}
- {fileID: 2092689135}
- {fileID: 602582428}
Expand Down Expand Up @@ -8998,7 +9023,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1405386638}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!114 &2092689136
MonoBehaviour:
Expand Down Expand Up @@ -9584,17 +9609,17 @@ PrefabInstance:
- target: {fileID: 5755280646380965414, guid: 6335a3f5d84d6421eb04d6f447784f85,
type: 3}
propertyPath: m_LocalPosition.x
value: 5
value: 4.64
objectReference: {fileID: 0}
- target: {fileID: 5755280646380965414, guid: 6335a3f5d84d6421eb04d6f447784f85,
type: 3}
propertyPath: m_LocalPosition.y
value: -4
value: -3.56
objectReference: {fileID: 0}
- target: {fileID: 5755280646380965434, guid: 6335a3f5d84d6421eb04d6f447784f85,
type: 3}
propertyPath: m_IsActive
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5755280646457188808, guid: 6335a3f5d84d6421eb04d6f447784f85,
type: 3}
Expand Down Expand Up @@ -9798,5 +9823,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 293ba996f8d224288996decbbd8734e0, type: 3}
m_Name:
m_EditorClassIdentifier:
period: 3
target: {fileID: 1072673124}
level: 2
stop: 0
19 changes: 16 additions & 3 deletions OdysseyNow/Assets/Scripts/AI/card4/catAndMouse/cat/CatAI.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class CatAI : MonoBehaviour
{

private float nextActionTime = 0.0f;
public float period = 5f;
public GameObject target;
public int level;
private NavMeshAgent agent;
public bool stop;


// Start is called before the first frame update
void Start()
Expand Down Expand Up @@ -38,7 +41,17 @@ void Update()

Debug.Log("Cat has the mouse.");
}
agent.SetDestination(target.transform.position);
switch(level){
case 1:
agent.SetDestination(target.transform.position);
break;
case 2:
if (Time.time > nextActionTime ) {
nextActionTime += Time.time + period;
agent.SetDestination(new Vector3(Random.Range(-4, 4), Random.Range(-4, 4), 0));
}
break;
}
//Navigate.DebugDrawPath(agent.path.corners);
}
}

0 comments on commit d3f0187

Please sign in to comment.