Complete speed platform

This commit is contained in:
haitem
2022-01-29 03:25:16 +01:00
parent 94950a79a1
commit 8aa168505d
8 changed files with 187 additions and 147 deletions

View File

@@ -6,6 +6,7 @@ public class PlatformManager : MonoBehaviour
{
public enum PlatformType {Pull, Push, RotateZ, RotateY, Speed};
public PlatformType type = PlatformType.Pull;
public float speed = 5;
void Start()
{
@@ -16,9 +17,9 @@ public class PlatformManager : MonoBehaviour
{
if (type == PlatformType.RotateZ)
{
transform.Rotate(transform.forward);
transform.Rotate(transform.forward * speed * Time.deltaTime);
} else if (type == PlatformType.RotateY) {
transform.Rotate(transform.up);
transform.Rotate(transform.up * speed * Time.deltaTime);
}
}
}

View File

@@ -97,6 +97,11 @@ public class PlayerController : MonoBehaviour
{
gDirection = -transform.up;
}
else if (platform != null && platform.type == PlatformManager.PlatformType.Speed)
{
rb.AddForce(other.transform.forward * platform.speed * 10 * Time.deltaTime, ForceMode.Impulse);
gDirection = -transform.up;
}
else
{
gDirection = -transform.up;