Changes made as suggested in code review (part2)
This commit is contained in:
parent
baad3163e6
commit
7c56c0defa
|
@ -140,31 +140,31 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.x
|
propertyPath: m_LocalRotation.x
|
||||||
value: 0.1208261
|
value: 0.120826095
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.y
|
propertyPath: m_LocalRotation.y
|
||||||
value: -0.000000036106464
|
value: 5.854628e-16
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: 0.0000000043948005
|
value: -3.9541625e-17
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.w
|
propertyPath: m_LocalRotation.w
|
||||||
value: 0.9907843
|
value: 0.9907814
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.x
|
propertyPath: m_LocalRotation.x
|
||||||
value: 0.1205961
|
value: 0.120595776
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.y
|
propertyPath: m_LocalRotation.y
|
||||||
value: 0.061217826
|
value: 0.061263908
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: -0.0074513005
|
value: -0.0074569103
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
|
@ -220,27 +220,27 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
value: -0.04899299
|
value: 0.5793742
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
value: 0.007368088
|
value: -0.05608368
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.w
|
propertyPath: m_LocalRotation.w
|
||||||
value: 0.9935528
|
value: 0.97916543
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.x
|
propertyPath: m_LocalRotation.x
|
||||||
value: 0.11337071
|
value: 0.2030643
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.y
|
propertyPath: m_LocalRotation.y
|
||||||
value: 0.00000002873854
|
value: -0.0000000033519971
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: -0.0000000032792506
|
value: 6.9515427e-10
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832858914730, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832858914730, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_XAxis.m_InvertInput
|
propertyPath: m_XAxis.m_InvertInput
|
||||||
|
@ -252,20 +252,36 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.w
|
propertyPath: m_LocalRotation.w
|
||||||
value: 0.9907843
|
value: 0.9907814
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.x
|
propertyPath: m_LocalRotation.x
|
||||||
value: 0.120596126
|
value: 0.12059577
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.y
|
propertyPath: m_LocalRotation.y
|
||||||
value: 0.06121782
|
value: 0.061263897
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: -0.007451302
|
value: -0.007456909
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8246265507772854771, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
|
propertyPath: animator
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 1052215608}
|
||||||
|
- target: {fileID: 8246265507772854771, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
|
propertyPath: _playerDeath
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 11400000, guid: 22fd384aef0d08146831d35c2ab7f983, type: 2}
|
||||||
|
- target: {fileID: 8246265507772854771, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
|
propertyPath: _playerRespawn
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 11400000, guid: 6e31084a96bb93a44a85563a6208d0da, type: 2}
|
||||||
|
- target: {fileID: 8246265507772854771, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
|
propertyPath: _respawnPosition
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 11400000, guid: 20fad56702134eb469a652ba680b48b2, type: 2}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
--- !u!1 &59318655
|
--- !u!1 &59318655
|
||||||
|
@ -493,7 +509,6 @@ MonoBehaviour:
|
||||||
speed: 4
|
speed: 4
|
||||||
waitToDestroy: 3
|
waitToDestroy: 3
|
||||||
direction: {x: 1, y: 0, z: 0}
|
direction: {x: 1, y: 0, z: 0}
|
||||||
dz: {fileID: 1148358023}
|
|
||||||
--- !u!65 &242293695
|
--- !u!65 &242293695
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -763,7 +778,6 @@ MonoBehaviour:
|
||||||
speed: 4
|
speed: 4
|
||||||
waitToDestroy: 3
|
waitToDestroy: 3
|
||||||
direction: {x: -1, y: 0, z: 0}
|
direction: {x: -1, y: 0, z: 0}
|
||||||
dz: {fileID: 1148358023}
|
|
||||||
--- !u!65 &412604039
|
--- !u!65 &412604039
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1291,7 +1305,6 @@ MonoBehaviour:
|
||||||
speed: 4
|
speed: 4
|
||||||
waitToDestroy: 3
|
waitToDestroy: 3
|
||||||
direction: {x: 1, y: 0, z: 0}
|
direction: {x: 1, y: 0, z: 0}
|
||||||
dz: {fileID: 1148358023}
|
|
||||||
--- !u!65 &897198734
|
--- !u!65 &897198734
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1740,11 +1753,6 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 5f1d0f28dfb6a7245ac9ab4193aaed55, type: 3}
|
m_Script: {fileID: 11500000, guid: 5f1d0f28dfb6a7245ac9ab4193aaed55, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
animator: {fileID: 1052215608}
|
|
||||||
fadeScreen: {fileID: 0}
|
|
||||||
_respawnPosition: {fileID: 11400000, guid: 20fad56702134eb469a652ba680b48b2, type: 2}
|
|
||||||
_playerDeath: {fileID: 11400000, guid: 22fd384aef0d08146831d35c2ab7f983, type: 2}
|
|
||||||
_playerRespawn: {fileID: 11400000, guid: 6e31084a96bb93a44a85563a6208d0da, type: 2}
|
|
||||||
--- !u!1 &1191416068
|
--- !u!1 &1191416068
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -2188,7 +2196,6 @@ MonoBehaviour:
|
||||||
speed: 4
|
speed: 4
|
||||||
waitToDestroy: 3
|
waitToDestroy: 3
|
||||||
direction: {x: -1, y: 0, z: 0}
|
direction: {x: -1, y: 0, z: 0}
|
||||||
dz: {fileID: 1148358023}
|
|
||||||
--- !u!65 &1492009516
|
--- !u!65 &1492009516
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -2380,7 +2387,6 @@ MonoBehaviour:
|
||||||
speed: 4
|
speed: 4
|
||||||
waitToDestroy: 3
|
waitToDestroy: 3
|
||||||
direction: {x: -1, y: 0, z: 0}
|
direction: {x: -1, y: 0, z: 0}
|
||||||
dz: {fileID: 1148358023}
|
|
||||||
--- !u!65 &1549198535
|
--- !u!65 &1549198535
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -2811,7 +2817,6 @@ MonoBehaviour:
|
||||||
speed: 4
|
speed: 4
|
||||||
waitToDestroy: 3
|
waitToDestroy: 3
|
||||||
direction: {x: 1, y: 0, z: 0}
|
direction: {x: 1, y: 0, z: 0}
|
||||||
dz: {fileID: 1148358023}
|
|
||||||
--- !u!65 &1875917607
|
--- !u!65 &1875917607
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -11,7 +11,6 @@ public class Arrow : MonoBehaviour
|
||||||
[SerializeField] private float waitToDestroy;
|
[SerializeField] private float waitToDestroy;
|
||||||
// Vector3 to set direction of travel for the arrow once the trigger is activated.
|
// Vector3 to set direction of travel for the arrow once the trigger is activated.
|
||||||
[SerializeField] private Vector3 direction;
|
[SerializeField] private Vector3 direction;
|
||||||
[SerializeField] private PlayerDeath pd;
|
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
@ -32,7 +31,7 @@ public class Arrow : MonoBehaviour
|
||||||
if (collision.gameObject.TryGetComponent(out PlayerDeath playerDeath))
|
if (collision.gameObject.TryGetComponent(out PlayerDeath playerDeath))
|
||||||
{
|
{
|
||||||
// Start Respawn coroutine.
|
// Start Respawn coroutine.
|
||||||
StartCoroutine(pd.RespawnPlayer());
|
playerDeath.Respawn();
|
||||||
// Destroy arrow on contact with player.
|
// Destroy arrow on contact with player.
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,4 @@ public class SafeZone : MonoBehaviour
|
||||||
_respawnPosition.Value = other.gameObject.transform.position;
|
_respawnPosition.Value = other.gameObject.transform.position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,19 +1,13 @@
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Ktyl.Util;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
|
||||||
public class DeathZone : MonoBehaviour
|
public class DeathZone : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private PlayerDeath pd;
|
private void OnCollisionEnter(Collision collision)
|
||||||
|
|
||||||
private void OnTriggerEnter(Collider other)
|
|
||||||
{
|
{
|
||||||
// Checks to make sure other collider is the Player. Sets player variable as Player game object and starts the coroutine.
|
// Checks to make sure other collider is the Player. Sets player variable as Player game object and starts the coroutine.
|
||||||
if (other.gameObject.CompareTag("Player"))
|
if (collision.gameObject.TryGetComponent(out PlayerDeath playerDeath))
|
||||||
{
|
{
|
||||||
StartCoroutine(pd.RespawnPlayer());
|
playerDeath.Respawn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,9 +14,14 @@ public class PlayerDeath : MonoBehaviour
|
||||||
[SerializeField] private GameEvent _playerDeath;
|
[SerializeField] private GameEvent _playerDeath;
|
||||||
[SerializeField] private GameEvent _playerRespawn;
|
[SerializeField] private GameEvent _playerRespawn;
|
||||||
|
|
||||||
|
public void Respawn()
|
||||||
|
{
|
||||||
|
StartCoroutine(RespawnPlayerCR());
|
||||||
|
}
|
||||||
|
|
||||||
// Corountine to trigger death animation, disable player movement, play fade,
|
// Corountine to trigger death animation, disable player movement, play fade,
|
||||||
// respawn player at last safe position and then play fade in animation and re-enable player movement.
|
// respawn player at last safe position and then play fade in animation and re-enable player movement.
|
||||||
public IEnumerator RespawnPlayer()
|
public IEnumerator RespawnPlayerCR()
|
||||||
{
|
{
|
||||||
animator.SetTrigger("IsDead");
|
animator.SetTrigger("IsDead");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue