Movement anpassungen (no slide while push)
This commit is contained in:
@@ -119,6 +119,73 @@ NavMeshSettings:
|
|||||||
debug:
|
debug:
|
||||||
m_Flags: 0
|
m_Flags: 0
|
||||||
m_NavMeshData: {fileID: 0}
|
m_NavMeshData: {fileID: 0}
|
||||||
|
--- !u!1 &67018399
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 67018400}
|
||||||
|
- component: {fileID: 67018402}
|
||||||
|
- component: {fileID: 67018401}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: StandUpCollider
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &67018400
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 67018399}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 955231359}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &67018401
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 67018399}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 19aae932aa4446c4788d84deb1116128, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::StandUpCollider
|
||||||
|
ispushing: 0
|
||||||
|
--- !u!135 &67018402
|
||||||
|
SphereCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 67018399}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_IsTrigger: 1
|
||||||
|
m_ProvidesContacts: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 3
|
||||||
|
m_Radius: 2
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &209519236
|
--- !u!1 &209519236
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1022,7 +1089,8 @@ Transform:
|
|||||||
m_LocalPosition: {x: -15.5, y: 1.23, z: 12.73}
|
m_LocalPosition: {x: -15.5, y: 1.23, z: 12.73}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children:
|
||||||
|
- {fileID: 67018400}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &955231360
|
--- !u!114 &955231360
|
||||||
@@ -1040,7 +1108,9 @@ MonoBehaviour:
|
|||||||
basespeed: 8
|
basespeed: 8
|
||||||
speed: 8
|
speed: 8
|
||||||
speedincrease: 0.05
|
speedincrease: 0.05
|
||||||
|
maxspeed: 15
|
||||||
slide: 0.2
|
slide: 0.2
|
||||||
|
standUp: {fileID: 0}
|
||||||
--- !u!114 &955231361
|
--- !u!114 &955231361
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1118,6 +1188,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: e7c1c3fec0605d746bddf36d1b260908, type: 3}
|
m_Script: {fileID: 11500000, guid: e7c1c3fec0605d746bddf36d1b260908, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Pit
|
m_EditorClassIdentifier: Assembly-CSharp::Pit
|
||||||
|
startmass: 0
|
||||||
--- !u!4 &1604116872
|
--- !u!4 &1604116872
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1127,7 +1198,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 1604116870}
|
m_GameObject: {fileID: 1604116870}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -2.3, y: -0.7, z: 13.1}
|
m_LocalPosition: {x: -2.3, y: -2.37, z: 13.1}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
public class Pit : MonoBehaviour
|
public class Pit : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public float startmass;
|
||||||
private void OnTriggerEnter(Collider other)
|
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();
|
other.GetComponent<PositionReset>().Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using Unity.VisualScripting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class PlayerMove : MonoBehaviour
|
public class PlayerMove : MonoBehaviour
|
||||||
@@ -7,17 +8,22 @@ public class PlayerMove : MonoBehaviour
|
|||||||
[SerializeField] private float basespeed;
|
[SerializeField] private float basespeed;
|
||||||
[SerializeField] private float speed;
|
[SerializeField] private float speed;
|
||||||
[SerializeField] private float speedincrease;
|
[SerializeField] private float speedincrease;
|
||||||
|
[SerializeField] private float maxspeed;
|
||||||
|
|
||||||
private Rigidbody rb;
|
private Rigidbody rb;
|
||||||
[SerializeField] private float slide;
|
[SerializeField] private float slide;
|
||||||
|
|
||||||
Vector3 moveDirection;
|
Vector3 moveDirection;
|
||||||
|
|
||||||
bool vertical;
|
bool vertical;
|
||||||
bool horizontal;
|
private bool horizontal;
|
||||||
|
|
||||||
|
[SerializeField] private StandUpCollider standUp;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
rb = GetComponent<Rigidbody>();
|
rb = GetComponent<Rigidbody>();
|
||||||
|
standUp = FindAnyObjectByType(typeof(StandUpCollider)) as StandUpCollider;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
@@ -31,12 +37,15 @@ public class PlayerMove : MonoBehaviour
|
|||||||
|
|
||||||
if (horizontalInput != 0 && horizontal == true)
|
if (horizontalInput != 0 && horizontal == true)
|
||||||
{
|
{
|
||||||
transform.rotation = Quaternion.Euler(0f, 0f, 90f);
|
if (!standUp.ispushing)
|
||||||
|
{
|
||||||
|
transform.rotation = Quaternion.Euler(0f, 0f, 90f);
|
||||||
|
}
|
||||||
vertical = false;
|
vertical = false;
|
||||||
moveDirection = new Vector3(horizontalInput,0, 0);
|
moveDirection = new Vector3(horizontalInput,0, 0);
|
||||||
moveDirection.Normalize();
|
moveDirection.Normalize();
|
||||||
|
|
||||||
if (!vertical)
|
if (!vertical && speed <= maxspeed && !standUp.ispushing)
|
||||||
{
|
{
|
||||||
speed += speedincrease;
|
speed += speedincrease;
|
||||||
}
|
}
|
||||||
@@ -44,12 +53,15 @@ public class PlayerMove : MonoBehaviour
|
|||||||
}
|
}
|
||||||
else if (verticalInput != 0 && vertical == true)
|
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;
|
horizontal = false;
|
||||||
moveDirection = new Vector3(0, 0, verticalInput);
|
moveDirection = new Vector3(0, 0, verticalInput);
|
||||||
moveDirection.Normalize();
|
moveDirection.Normalize();
|
||||||
|
|
||||||
if (!horizontal)
|
if (!horizontal && speed <= maxspeed && !standUp.ispushing)
|
||||||
{
|
{
|
||||||
speed += speedincrease;
|
speed += speedincrease;
|
||||||
}
|
}
|
||||||
@@ -77,4 +89,8 @@ public class PlayerMove : MonoBehaviour
|
|||||||
speed = basespeed;
|
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