Merged Wall and Ground Enemies into One

This commit is contained in:
Syntriax 2022-02-22 00:47:26 +03:00
parent cbcb05b845
commit 6e7a90fd86
12 changed files with 32 additions and 246 deletions

View File

@ -1,76 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &6096204647932119543
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalPosition.x
value: 2.52
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalPosition.y
value: 0.684
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7391517555913877016, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_Name
value: Basic Ground Patrolling Enemy
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
--- !u!1 &3605663502554574831 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 7391517555913877016, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
m_PrefabInstance: {fileID: 6096204647932119543}
m_PrefabAsset: {fileID: 0}
--- !u!114 &7978713
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3605663502554574831}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4ae10931055aaa44d8c518e9efa3d034, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 1bf2cdb83af1d714ab363c6c4d1d140e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -79,6 +79,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7000c8c0eb91b2d4cb9a0e3ee1b609a7, type: 3} m_Script: {fileID: 11500000, guid: 7000c8c0eb91b2d4cb9a0e3ee1b609a7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
layerMask:
serializedVersion: 2
m_Bits: 4294967103
--- !u!1 &5991452379241120368 --- !u!1 &5991452379241120368
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -123,6 +126,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7000c8c0eb91b2d4cb9a0e3ee1b609a7, type: 3} m_Script: {fileID: 11500000, guid: 7000c8c0eb91b2d4cb9a0e3ee1b609a7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
layerMask:
serializedVersion: 2
m_Bits: 4294967103
--- !u!1 &7391517555913877016 --- !u!1 &7391517555913877016
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -137,7 +143,7 @@ GameObject:
- component: {fileID: 1030411162175245191} - component: {fileID: 1030411162175245191}
- component: {fileID: 8503951513957676288} - component: {fileID: 8503951513957676288}
m_Layer: 7 m_Layer: 7
m_Name: Basic Patrolling Enemy Base m_Name: Basic Patrolling Enemy
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@ -297,7 +303,7 @@ Transform:
m_GameObject: {fileID: 7883981671222168568} m_GameObject: {fileID: 7883981671222168568}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.8, y: 0, z: 0} m_LocalPosition: {x: -0.8, y: 0, z: 0}
m_LocalScale: {x: 0.5, y: 0.75, z: 1} m_LocalScale: {x: 0.5, y: 0.5, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 334282908223700766} m_Father: {fileID: 334282908223700766}
@ -315,6 +321,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7000c8c0eb91b2d4cb9a0e3ee1b609a7, type: 3} m_Script: {fileID: 11500000, guid: 7000c8c0eb91b2d4cb9a0e3ee1b609a7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
layerMask:
serializedVersion: 2
m_Bits: 4294967231
--- !u!1 &7984300476647789986 --- !u!1 &7984300476647789986
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -341,7 +350,7 @@ Transform:
m_GameObject: {fileID: 7984300476647789986} m_GameObject: {fileID: 7984300476647789986}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.8, y: 0, z: 0} m_LocalPosition: {x: 0.8, y: 0, z: 0}
m_LocalScale: {x: 0.5, y: 0.75, z: 1} m_LocalScale: {x: 0.5, y: 0.5, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 334282908223700766} m_Father: {fileID: 334282908223700766}
@ -359,3 +368,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7000c8c0eb91b2d4cb9a0e3ee1b609a7, type: 3} m_Script: {fileID: 11500000, guid: 7000c8c0eb91b2d4cb9a0e3ee1b609a7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
layerMask:
serializedVersion: 2
m_Bits: 4294967231

View File

@ -1,104 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &460717884008149060
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 334282908223700766, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 334282908223700766, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalRotation.z
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 334282908223700766, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 90
objectReference: {fileID: 0}
- target: {fileID: 3171748321895642525, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalScale.x
value: 0.75
objectReference: {fileID: 0}
- target: {fileID: 3171748321895642525, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalScale.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalPosition.x
value: -5.25
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalPosition.y
value: 0.684
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7391517555913877016, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_Name
value: Basic Wall Patrollling Enemy
objectReference: {fileID: 0}
- target: {fileID: 7648712865646313035, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalScale.x
value: 0.75
objectReference: {fileID: 0}
- target: {fileID: 7648712865646313035, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
propertyPath: m_LocalScale.y
value: 0.5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
--- !u!1 &6987122029433902684 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 7391517555913877016, guid: c0a2079a443363b4da73a0d425221f6c, type: 3}
m_PrefabInstance: {fileID: 460717884008149060}
m_PrefabAsset: {fileID: 0}
--- !u!114 &286786288
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6987122029433902684}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: adfb41bcf8c09e94ea1e95e22a4c7533, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 10633caf39c49d94c9f68742db900612
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -31,7 +31,7 @@ namespace AI
protected virtual void Awake() protected virtual void Awake()
{ {
movement = gameObject.GetComponent<EnemyMovement>(); movement = gameObject.AddComponent<EnemyMovement>();
leftWallChecker = GetCollisionCheckerOnChild("Collision Checkers/Left Wall"); leftWallChecker = GetCollisionCheckerOnChild("Collision Checkers/Left Wall");
rightWallChecker = GetCollisionCheckerOnChild("Collision Checkers/Right Wall"); rightWallChecker = GetCollisionCheckerOnChild("Collision Checkers/Right Wall");
leftGroundChecker = GetCollisionCheckerOnChild("Collision Checkers/Left Ground"); leftGroundChecker = GetCollisionCheckerOnChild("Collision Checkers/Left Ground");

View File

@ -6,6 +6,7 @@ namespace Movement
public class EnemyMovement : MonoBehaviour, IMovement public class EnemyMovement : MonoBehaviour, IMovement
{ {
protected Rigidbody2D _rigidbody2D = null; protected Rigidbody2D _rigidbody2D = null;
protected Vector2 gravityForce = Vector2.down;
protected bool _isPaused = false; protected bool _isPaused = false;
protected float moveValue = 0f; protected float moveValue = 0f;
@ -13,16 +14,23 @@ namespace Movement
public bool IsPaused => _isPaused; public bool IsPaused => _isPaused;
protected virtual void Awake() protected virtual void Awake()
=> _rigidbody2D = GetComponent<Rigidbody2D>(); {
_rigidbody2D = GetComponent<Rigidbody2D>();
_rigidbody2D.gravityScale = 0f;
gravityForce *= -Physics2D.gravity.y * _rigidbody2D.mass;
}
protected virtual void FixedUpdate() protected virtual void FixedUpdate()
{ {
_rigidbody2D.AddRelativeForce(gravityForce);
if (IsPaused) if (IsPaused)
return; return;
Vector2 velocity = _rigidbody2D.velocity; Vector2 velocity = transform.InverseTransformDirection(_rigidbody2D.velocity);
velocity.x = moveValue; velocity.x = moveValue;
_rigidbody2D.velocity = velocity; _rigidbody2D.velocity = transform.TransformDirection(velocity);
} }
public void Move(float value) public void Move(float value)

View File

@ -1,29 +0,0 @@
using UnityEngine;
namespace Movement
{
public class EnemyVerticalMovement : EnemyMovement
{
protected Vector2 gravityForce = Vector2.right;
protected override void Awake()
{
base.Awake();
_rigidbody2D.gravityScale = 0f;
gravityForce *= -Physics2D.gravity.y * _rigidbody2D.mass;
}
protected override void FixedUpdate()
{
_rigidbody2D.AddRelativeForce(gravityForce);
if (IsPaused)
return;
Vector2 velocity = _rigidbody2D.velocity;
velocity.y = moveValue;
_rigidbody2D.velocity = velocity;
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: adfb41bcf8c09e94ea1e95e22a4c7533
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,10 +7,10 @@ namespace Player
{ {
public class PlayerController : MonoBehaviour, IMovement, Input.PlayerInput.IPlayerControlActions public class PlayerController : MonoBehaviour, IMovement, Input.PlayerInput.IPlayerControlActions
{ {
private const float DefaultJumpForce = 1200.0f; private const float DefaultJumpForce = 784.0f;
private const float DefaultMass = 80.0f; private const float DefaultMass = 80.0f;
private const float DefaultSpeed = 500.0f; private const float DefaultSpeed = 500.0f;
private const float GravityScale = 3.0f; private const float GravityScale = 1.0f;
private Input.PlayerInput _controls; private Input.PlayerInput _controls;
private Rigidbody2D _playerRigidbody2D; private Rigidbody2D _playerRigidbody2D;
@ -139,4 +139,4 @@ namespace Player
} }
} }
} }
} }

View File

@ -9,10 +9,10 @@ EditorUserSettings:
value: 515250075c0c595e5f5a5e71122159444e4e4a2f7a7d7f602f284d66b4b76661 value: 515250075c0c595e5f5a5e71122159444e4e4a2f7a7d7f602f284d66b4b76661
flags: 0 flags: 0
RecentlyUsedSceneGuid-1: RecentlyUsedSceneGuid-1:
value: 06550c57540350025c0b0f2747220a44174f4b73297070642b714465b0e6366e value: 5002060403010b5f0f560e7a47260a444f4f1e2e2f2e27312f7f4536e0b6633d
flags: 0 flags: 0
RecentlyUsedSceneGuid-2: RecentlyUsedSceneGuid-2:
value: 5002060403010b5f0f560e7a47260a444f4f1e2e2f2e27312f7f4536e0b6633d value: 06550c57540350025c0b0f2747220a44174f4b73297070642b714465b0e6366e
flags: 0 flags: 0
vcSharedLogLevel: vcSharedLogLevel:
value: 0d5e400f0650 value: 0d5e400f0650