Pit more versatile

This commit is contained in:
2026-01-23 19:20:39 +01:00
parent 9c1ac2c040
commit 3257f23245
6 changed files with 44 additions and 37 deletions
-6
View File
@@ -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
View File
@@ -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();
}
}
+1 -5
View File
@@ -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)
{
+11
View File
@@ -0,0 +1,11 @@
using UnityEngine;
public class PositionReset : MonoBehaviour
{
[SerializeField] private Vector3 StartPos;
public void Reset()
{
this.transform.position = StartPos;
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8fc662358fbf8394d804207b2a8c9868