wandering implemented

This commit is contained in:
jonasty 2022-04-25 17:41:22 +03:00
parent fd683b4580
commit a748b342a8
18 changed files with 325 additions and 233 deletions

View File

@ -122,7 +122,7 @@ Material:
- _WavingTint: {r: 1, g: 1, b: 1, a: 1}
- _Wind: {r: 1, g: 1, b: 4, a: 8}
m_BuildTextureStacks: []
--- !u!114 &3571172967903663832
--- !u!114 &271370933472182076
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}

View File

@ -123,7 +123,7 @@ Material:
- _WavingTint: {r: 1, g: 1, b: 1, a: 1}
- _Wind: {r: 1, g: 1, b: 4, a: 8}
m_BuildTextureStacks: []
--- !u!114 &280269339420870476
--- !u!114 &2538816319711087327
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}

View File

@ -1,18 +1,5 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-8157234245191131702
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -95,3 +82,16 @@ Material:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
--- !u!114 &4609426864682373882
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -1,18 +1,5 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-7227342547990357574
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -178,3 +165,16 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
--- !u!114 &8648607517174720714
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -1,6 +1,6 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-1491364163425350603
--- !u!114 &-3597665421656311537
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}

View File

@ -1,5 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-215921062122507535
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -173,16 +186,3 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
--- !u!114 &1629948885692042799
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -1,5 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-3013306715965619580
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -97,16 +110,3 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
--- !u!114 &5220444891309534584
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -1,18 +1,5 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-1389114357912770728
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -93,3 +80,16 @@ Material:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
--- !u!114 &7138810400319773702
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -231,19 +231,25 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: EnemyInAggroRange
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: EnemyInAttackRange
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: Wandering
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@ -1037,7 +1043,7 @@ AnimatorStateMachine:
m_Position: {x: 670, y: 550, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102835054974116572}
m_Position: {x: 280, y: 510, z: 0}
m_Position: {x: 280, y: 500, z: 0}
- serializedVersion: 1
m_State: {fileID: 8194647877007136643}
m_Position: {x: 300, y: 220, z: 0}
@ -1064,7 +1070,10 @@ AnimatorStateTransition:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: Wandering
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102546605246812244}
m_Solo: 0
@ -1086,7 +1095,10 @@ AnimatorStateTransition:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Wandering
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102508070621265122}
m_Solo: 0

View File

@ -362,6 +362,7 @@ GameObject:
- component: {fileID: 9217037737240071080}
- component: {fileID: 979664278525990523}
- component: {fileID: 7068053744138324038}
- component: {fileID: -8446248727669723812}
m_Layer: 0
m_Name: BossSlime
m_TagString: BossSlime
@ -418,6 +419,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2a6f17609e4d7c441b8f85c0f90c1a13, type: 3}
m_Name:
m_EditorClassIdentifier:
moveSpeed: 1
rotSpeed: 50
--- !u!54 &979664278525990523
Rigidbody:
m_ObjectHideFlags: 0
@ -447,6 +450,28 @@ SphereCollider:
serializedVersion: 2
m_Radius: 0.6
m_Center: {x: 0, y: 0.5, z: 0}
--- !u!195 &-8446248727669723812
NavMeshAgent:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8437010424349675124}
m_Enabled: 1
m_AgentTypeID: 0
m_Radius: 0.5
m_Speed: 3.5
m_Acceleration: 8
avoidancePriority: 50
m_AngularSpeed: 120
m_StoppingDistance: 0
m_AutoTraverseOffMeshLink: 1
m_AutoBraking: 1
m_AutoRepath: 1
m_Height: 2
m_BaseOffset: 0
m_WalkableMask: 4294967295
m_ObstacleAvoidanceType: 4
--- !u!1 &8437097380876049792
GameObject:
m_ObjectHideFlags: 0

View File

@ -362,6 +362,7 @@ GameObject:
- component: {fileID: 9217037737240071080}
- component: {fileID: 979664278525990523}
- component: {fileID: 6363954507592996496}
- component: {fileID: 8521358267821330725}
m_Layer: 0
m_Name: SlimePBR
m_TagString: Slime
@ -418,6 +419,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2a6f17609e4d7c441b8f85c0f90c1a13, type: 3}
m_Name:
m_EditorClassIdentifier:
moveSpeed: 1
rotSpeed: 100
--- !u!54 &979664278525990523
Rigidbody:
m_ObjectHideFlags: 0
@ -447,6 +450,28 @@ SphereCollider:
serializedVersion: 2
m_Radius: 0.6
m_Center: {x: 0, y: 0.5, z: 0}
--- !u!195 &8521358267821330725
NavMeshAgent:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8437010424349675124}
m_Enabled: 1
m_AgentTypeID: 0
m_Radius: 0.5
m_Speed: 3.5
m_Acceleration: 8
avoidancePriority: 50
m_AngularSpeed: 120
m_StoppingDistance: 0
m_AutoTraverseOffMeshLink: 1
m_AutoBraking: 1
m_AutoRepath: 1
m_Height: 1
m_BaseOffset: 0
m_WalkableMask: 4294967295
m_ObstacleAvoidanceType: 4
--- !u!1 &8437097380876049792
GameObject:
m_ObjectHideFlags: 0

View File

@ -11,7 +11,7 @@ public class SlimeAI : MonoBehaviour
GameObject player;
int HP;
public float moveSpeed = 3f;
public float moveSpeed = 4f;
public float rotSpeed = 100f;
private bool isWandering = false;
@ -28,6 +28,7 @@ public class SlimeAI : MonoBehaviour
animator = GetComponent<Animator>();
player = GameObject.FindWithTag("Player");
HP = 10;
}
// Update is called once per frame
@ -36,6 +37,7 @@ public class SlimeAI : MonoBehaviour
playerDistance = Vector3.Distance(player.transform.position, transform.position);
if (playerDistance < 1.5) //Attack
{
animator.SetBool("Wandering", false);
animator.SetBool("EnemyInAttackRange", true);
animator.SetBool("EnemyInAggroRange", true);
animator.SetBool("EnemyInVisionRange", true);
@ -43,6 +45,7 @@ public class SlimeAI : MonoBehaviour
}
else if (playerDistance < 10) //Chase
{
animator.SetBool("Wandering", false);
animator.SetBool("EnemyInAttackRange", false);
animator.SetBool("EnemyInAggroRange", true);
animator.SetBool("EnemyInVisionRange", true);
@ -51,33 +54,42 @@ public class SlimeAI : MonoBehaviour
}
else if (playerDistance < 18) //Stare
{
animator.SetBool("Wandering", false);
animator.SetBool("EnemyInAttackRange", false);
animator.SetBool("EnemyInAggroRange", false);
animator.SetBool("EnemyInVisionRange", true);
Rotate();
StopCoroutine("Wandering");
}
else //Idle
else
{
animator.SetBool("EnemyInAttackRange", false);
animator.SetBool("EnemyInAggroRange", false);
animator.SetBool("EnemyInVisionRange", false);
}
if (!isWandering)
{
//Idle
StartCoroutine("Wander");
if (isRotatingRight == true)
{
gameObject.GetComponent<Animator>().Play("IdleNormal");
transform.Rotate(transform.up * Time.deltaTime * rotSpeed);
}
if (isRotatingLeft == true)
{
gameObject.GetComponent<Animator>().Play("IdleNormal");
transform.Rotate(transform.up * Time.deltaTime * -rotSpeed);
}
if (isWalking == true)
{
gameObject.GetComponent<Animator>().Play("WalkFWD");
transform.position += transform.forward * moveSpeed * Time.deltaTime;
}
}
Debug.Log(isWandering);
Debug.Log(isRotatingLeft);
Debug.Log(isRotatingRight);
if (isRotatingRight == true)
{
animator.SetBool("Wandering", false);
transform.Rotate(transform.up * Time.deltaTime * rotSpeed);
}
if (isRotatingLeft == true)
{
animator.SetBool("Wandering", false);
transform.Rotate(transform.up * Time.deltaTime * -rotSpeed);
}
if (isWalking == true)
{
animator.SetBool("Wandering", true);
transform.position += transform.forward * moveSpeed * Time.deltaTime;
}
if (HP <= 0)
{
@ -112,10 +124,10 @@ public class SlimeAI : MonoBehaviour
IEnumerator Wander()
{
int rotTime = Random.Range(1, 3);
int rotateWait = Random.Range(1, 4);
int rotateWait = Random.Range(1, 5);
int rotateLorR = Random.Range(1, 2);
int walkWait = Random.Range(1, 5);
int walkTime = Random.Range(1, 6);
int walkTime = Random.Range(1, 20);
isWandering = true;

View File

@ -29,7 +29,7 @@ public class SlimeSpawner : MonoBehaviour
{
float slimeRandom = Random.Range(0, slimeTypes.Count);
float spawnRandom = Random.Range(0, spawnLocations.Count);
Instantiate(slimeTypes[Mathf.RoundToInt(slimeRandom)], spawnLocations[Mathf.RoundToInt(spawnRandom)].position, Quaternion.identity);
Instantiate(slimeTypes[Mathf.RoundToInt(slimeRandom)], spawnLocations[Mathf.RoundToInt(spawnRandom)].position, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f));
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9e3cc957f00ba754196d033975851083
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e97b658bf81e64e438a5af4cce8abe6d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 23800000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -90,19 +90,19 @@ Material:
- _HorizonCloudSize: 4.91
- _HorizonCloudStartPosition: -0.1
- _HorizonCloudStep: 25
- _HorizonExponent: 4.212204
- _HorizonExponent: 3.3921747
- _HorizonStep: 500
- _HorizonThickness: 1
- _MoonGlow: 0
- _MoonLightIntensity: 0.11609189
- _MoonLightIntensity: 0.00034078956
- _MoonSize: 0
- _MoonSoftEdge: 0
- _OverheadCloudAltitude: 1000
- _OverheadCloudAnimationSpeed: 50
- _OverheadCloudFlowDirectionX: 1
- _OverheadCloudFlowDirectionZ: 1
- _OverheadCloudRemapMax: 1
- _OverheadCloudRemapMin: -0.40113193
- _OverheadCloudRemapMax: 1.074074
- _OverheadCloudRemapMin: 0.111940965
- _OverheadCloudSize: 10
- _OverheadCloudStep: 2
- _StarsDensity0: 0.4
@ -112,7 +112,7 @@ Material:
- _StarsGlow0: 0.01
- _StarsGlow1: 0.01
- _StarsGlow2: 0.01
- _StarsOpacity: 0.77006197
- _StarsOpacity: 0.0009148121
- _StarsSize0: 0.42
- _StarsSize1: 0.53
- _StarsSize2: 0.46
@ -121,25 +121,25 @@ Material:
- _StarsTwinkle1: 6
- _StarsTwinkle2: 2
- _SunGlow: 0.45
- _SunLightIntensity: 0.00026742788
- _SunLightIntensity: 0.22252172
- _SunSize: 0.1
- _SunSoftEdge: 0.5
m_Colors:
- _DetailOverlayTintColor: {r: 0, g: 0, b: 0, a: 0}
- _FogColor: {r: 0, g: 0, b: 0, a: 0}
- _GroundColor: {r: 0.32409453, g: 0.28410664, b: 0.36156124, a: 1}
- _GroundColor: {r: 0.4100945, g: 0.38965663, b: 0.42924377, a: 1}
- _HorizonCloudColor: {r: 1, g: 1, b: 1, a: 1}
- _HorizonColor: {r: 0.4159287, g: 0.36391956, b: 0.5471698, a: 1}
- _MoonColor: {r: 1, g: 1, b: 1, a: 1}
- _HorizonColor: {r: 0.9055729, g: 0.85231304, b: 0.741789, a: 1}
- _MoonColor: {r: 1, g: 1, b: 1, a: 0}
- _MoonDirection: {r: 1, g: 1, b: 1, a: 0}
- _MoonLightColor: {r: 0, g: 0, b: 0, a: 0}
- _OverheadCloudColor: {r: 1, g: 1, b: 1, a: 0.8412408}
- _SkyColor: {r: 0.08056989, g: 0.03172837, b: 0.21698111, a: 1}
- _OverheadCloudColor: {r: 1, g: 1, b: 1, a: 0.9640542}
- _SkyColor: {r: 0.20533016, g: 0.35421106, b: 0.5882197, a: 1}
- _StarsColor0: {r: 0.96470594, g: 0.9450981, b: 0.76470596, a: 1}
- _StarsColor1: {r: 1, g: 0.5294118, b: 0.93725497, a: 1}
- _StarsColor2: {r: 0, g: 0.92549026, b: 1, a: 1}
- _SunColor: {r: 0.991845, g: 0.9783889, b: 0.95618623, a: 0}
- _SunDirection: {r: 0, g: 0.8362344, b: 0.54837215, a: 0}
- _SunColor: {r: 0.9742516, g: 0.93176544, b: 0.86166334, a: 1}
- _SunDirection: {r: 0, g: -0.258819, b: 0.9659258, a: 0}
- _SunLightColor: {r: 1, g: 0.9929226, b: 0.9009434, a: 1}
m_BuildTextureStacks: []
--- !u!114 &11400000