Edit palyer script

This commit is contained in:
haitem 2022-01-30 14:26:39 +01:00
parent 8a342d35c6
commit 66d62feffa

View File

@ -39,8 +39,6 @@ public class PlayerController : MonoBehaviour
private Vector3 saveDirection; private Vector3 saveDirection;
private Vector3 downDirection; private Vector3 downDirection;
private Vector3 platformForward;
private Vector3 platformRight;
private Vector3 follow = Vector3.zero; private Vector3 follow = Vector3.zero;
@ -50,8 +48,6 @@ public class PlayerController : MonoBehaviour
void Start() void Start()
{ {
rb = GetComponent<Rigidbody>(); rb = GetComponent<Rigidbody>();
platformForward = Vector3.forward;
platformRight = Vector3.right;
} }
public void disableCursor() public void disableCursor()
@ -72,7 +68,7 @@ public class PlayerController : MonoBehaviour
isRunning = Input.GetKey(KeyCode.LeftShift); isRunning = Input.GetKey(KeyCode.LeftShift);
if (canMove && currentSpeed < minSpeed) if (canMove && currentSpeed < minSpeed)
{ {
currentSpeed += 0.005f; currentSpeed += 0.01f;
} }
if (Input.GetAxis("Vertical") > 0 && currentSpeed < maxSpeed) if (Input.GetAxis("Vertical") > 0 && currentSpeed < maxSpeed)
@ -202,10 +198,10 @@ public class PlayerController : MonoBehaviour
switch (platform.type) switch (platform.type)
{ {
case PlatformManager.PlatformType.Push: case PlatformManager.PlatformType.Push:
rb.AddForce(-(other.transform.position - transform.position) * step, ForceMode.Impulse); rb.AddForce(-saveDirection * step, ForceMode.VelocityChange);
break; break;
case PlatformManager.PlatformType.Pull: case PlatformManager.PlatformType.Pull:
rb.AddForce((other.transform.position - transform.position) * step, ForceMode.Impulse); rb.AddForce(saveDirection * step, ForceMode.VelocityChange);
break; break;
} }
} }
@ -291,8 +287,6 @@ public class PlayerController : MonoBehaviour
{ {
gDirection = -transform.up; gDirection = -transform.up;
} }
platformForward = other.transform.forward;
platformRight = other.transform.right;
this.downDirection = gDirection; this.downDirection = gDirection;
Physics.gravity = gDirection * 9.81f; Physics.gravity = gDirection * 9.81f;
} }