Movement anpassungen (no slide while push)

This commit is contained in:
2026-01-24 13:27:39 +01:00
parent 3257f23245
commit 4a4e3be216
5 changed files with 127 additions and 8 deletions
+6
View File
@@ -1,10 +1,16 @@
using System;
using UnityEngine;
using UnityEngine.Serialization;
public class Pit : MonoBehaviour
{
public float startmass;
private void OnTriggerEnter(Collider other)
{
if (other.isTrigger) return;
startmass = other.GetComponent<Rigidbody>().mass;
other.GetComponent<Rigidbody>().mass = 100;
other.GetComponent<Rigidbody>().mass = startmass;
other.GetComponent<PositionReset>().Reset();
}
}
+22 -6
View File
@@ -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;
}
}
+24
View File
@@ -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