Pit more versatile
This commit is contained in:
@@ -5,7 +5,6 @@ public class IceBlockPush : MonoBehaviour
|
||||
{
|
||||
[SerializeField] float contactForce = 2.5f;
|
||||
private Rigidbody rb;
|
||||
[SerializeField] private Vector3 StartPos;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -35,9 +34,4 @@ public class IceBlockPush : MonoBehaviour
|
||||
|
||||
rb.AddForce(directionVector * contactForce, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.transform.position = StartPos;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-21
@@ -3,28 +3,8 @@ using UnityEngine;
|
||||
|
||||
public class Pit : MonoBehaviour
|
||||
{
|
||||
public PlayerMove player;
|
||||
public IceBlockPush ice;
|
||||
//
|
||||
// // Update is called once per frame
|
||||
// void Update()
|
||||
// {
|
||||
// if (Input.GetKeyDown(KeyCode.Space))
|
||||
// {
|
||||
// player.Reset();
|
||||
// ice.Reset();
|
||||
// }
|
||||
// }
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.GetComponent<PlayerMove>())
|
||||
{
|
||||
player.Reset();
|
||||
}
|
||||
else if(other.GetComponent<IceBlockPush>())
|
||||
{
|
||||
ice.Reset();
|
||||
}
|
||||
other.GetComponent<PositionReset>().Reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ public class PlayerMove : MonoBehaviour
|
||||
[SerializeField] private float speed;
|
||||
[SerializeField] private float speedincrease;
|
||||
private Rigidbody rb;
|
||||
[SerializeField] private Vector3 StartPos;
|
||||
[SerializeField] private float slide;
|
||||
|
||||
Vector3 moveDirection;
|
||||
@@ -67,10 +66,7 @@ public class PlayerMove : MonoBehaviour
|
||||
transform.Translate(moveDirection * speed * Time.deltaTime, Space.World);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.transform.position = StartPos;
|
||||
}
|
||||
|
||||
|
||||
IEnumerator Slide(float delay)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class PositionReset : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Vector3 StartPos;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.transform.position = StartPos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fc662358fbf8394d804207b2a8c9868
|
||||
Reference in New Issue
Block a user