Movement anpassungen (no slide while push)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerMove : MonoBehaviour
|
||||
@@ -7,17 +8,22 @@ public class PlayerMove : MonoBehaviour
|
||||
[SerializeField] private float basespeed;
|
||||
[SerializeField] private float speed;
|
||||
[SerializeField] private float speedincrease;
|
||||
[SerializeField] private float maxspeed;
|
||||
|
||||
private Rigidbody rb;
|
||||
[SerializeField] private float slide;
|
||||
|
||||
Vector3 moveDirection;
|
||||
|
||||
bool vertical;
|
||||
bool horizontal;
|
||||
|
||||
private bool horizontal;
|
||||
|
||||
[SerializeField] private StandUpCollider standUp;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
standUp = FindAnyObjectByType(typeof(StandUpCollider)) as StandUpCollider;
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -31,12 +37,15 @@ public class PlayerMove : MonoBehaviour
|
||||
|
||||
if (horizontalInput != 0 && horizontal == true)
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(0f, 0f, 90f);
|
||||
if (!standUp.ispushing)
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(0f, 0f, 90f);
|
||||
}
|
||||
vertical = false;
|
||||
moveDirection = new Vector3(horizontalInput,0, 0);
|
||||
moveDirection.Normalize();
|
||||
|
||||
if (!vertical)
|
||||
if (!vertical && speed <= maxspeed && !standUp.ispushing)
|
||||
{
|
||||
speed += speedincrease;
|
||||
}
|
||||
@@ -44,12 +53,15 @@ public class PlayerMove : MonoBehaviour
|
||||
}
|
||||
else if (verticalInput != 0 && vertical == true)
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(90f, 0f, 0f);
|
||||
if (!standUp.ispushing)
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(90f, 0f, 0f);
|
||||
}
|
||||
horizontal = false;
|
||||
moveDirection = new Vector3(0, 0, verticalInput);
|
||||
moveDirection.Normalize();
|
||||
|
||||
if (!horizontal)
|
||||
if (!horizontal && speed <= maxspeed && !standUp.ispushing)
|
||||
{
|
||||
speed += speedincrease;
|
||||
}
|
||||
@@ -77,4 +89,8 @@ public class PlayerMove : MonoBehaviour
|
||||
speed = basespeed;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class StandUpCollider : MonoBehaviour
|
||||
{
|
||||
public bool ispushing;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
IceBlockPush block = other.gameObject.GetComponent<IceBlockPush>();
|
||||
if (block != null)
|
||||
{
|
||||
ispushing = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
IceBlockPush block = other.gameObject.GetComponent<IceBlockPush>();
|
||||
if (block != null)
|
||||
{
|
||||
ispushing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19aae932aa4446c4788d84deb1116128
|
||||
Reference in New Issue
Block a user