refactored PlayerController
This commit is contained in:
parent
81d813ade8
commit
d25e7cd1e8
@ -132,7 +132,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 13
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -194,7 +194,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 4
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -256,7 +256,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 11
|
||||
value: 8
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -348,13 +348,13 @@ Transform:
|
||||
- {fileID: 258401669}
|
||||
- {fileID: 1620023971}
|
||||
- {fileID: 39090895}
|
||||
- {fileID: 358391054}
|
||||
- {fileID: 1575825840}
|
||||
- {fileID: 740849107}
|
||||
- {fileID: 1932669296}
|
||||
- {fileID: 1355937531}
|
||||
- {fileID: 358391054}
|
||||
- {fileID: 574603077}
|
||||
- {fileID: 559456472}
|
||||
- {fileID: 574603077}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -367,7 +367,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 18
|
||||
value: 11
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -429,7 +429,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 18
|
||||
value: 16
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -491,7 +491,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 19
|
||||
value: 17
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -573,7 +573,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 7
|
||||
value: 4
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -634,7 +634,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 6
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -785,7 +785,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 5
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -842,7 +842,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 15
|
||||
value: 13
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -904,7 +904,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 10
|
||||
value: 7
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -961,7 +961,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 9
|
||||
value: 6
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -1071,24 +1071,6 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3}
|
||||
m_PrefabInstance: {fileID: 613611969}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &1172583617 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 3244356566819001084, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
m_PrefabInstance: {fileID: 1953646381}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!65 &1172583624
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1172583617}
|
||||
m_Material: {fileID: 13400000, guid: 055b414bc685d41409a41f4ea2d64231, type: 2}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 2, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!4 &1210902573 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3}
|
||||
@ -1108,7 +1090,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 17
|
||||
value: 15
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -1180,7 +1162,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 14
|
||||
value: 12
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -1242,7 +1224,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 12
|
||||
value: 9
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -1353,7 +1335,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 16
|
||||
value: 14
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -1418,37 +1400,9 @@ PrefabInstance:
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 3244356566819001072, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3244356566819001073, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3244356566819001085, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3244356566819001085, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3244356566819001086, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
propertyPath: jump.y
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3244356566819001086, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
propertyPath: jumpForce
|
||||
value: 5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3244356566819001086, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
propertyPath: jumpSpeed
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3244356566819001087, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 2
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 3.67
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3244356567786994344, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
propertyPath: m_Name
|
||||
@ -1498,15 +1452,8 @@ PrefabInstance:
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3244356567913423212, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0.55
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3244356567913423212, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -0.68
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedComponents:
|
||||
- {fileID: 5651099808780516101, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
|
||||
--- !u!4 &2009655149 stripped
|
||||
Transform:
|
||||
@ -1522,7 +1469,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 8
|
||||
value: 5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
@ -1579,7 +1526,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 1
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
|
@ -100,7 +100,8 @@ public class PlayerController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void OnCollisionStay(Collision other) {
|
||||
void OnCollisionStay(Collision other)
|
||||
{
|
||||
if (other.gameObject.tag != "platform") return;
|
||||
PlatformManager platform = other.gameObject.GetComponent<PlatformManager>();
|
||||
if (platform == null)
|
||||
@ -135,37 +136,28 @@ public class PlayerController : MonoBehaviour
|
||||
|
||||
Vector3 gDirection;
|
||||
PlatformManager platform = other.gameObject.GetComponent<PlatformManager>();
|
||||
gDirection = -transform.up;
|
||||
if (platform == null)
|
||||
gDirection = -other.GetContact(0).normal;
|
||||
switch (platform.type)
|
||||
{
|
||||
// FIXME: remove
|
||||
this.downDirection = -transform.up;
|
||||
return;
|
||||
}
|
||||
if (platform.type == PlatformManager.PlatformType.Pull)
|
||||
{
|
||||
gDirection = -other.GetContact(0).normal;
|
||||
}
|
||||
else if (platform.type == PlatformManager.PlatformType.Push)
|
||||
{
|
||||
gDirection = -other.GetContact(0).normal;
|
||||
}
|
||||
else if ((platform.type == PlatformManager.PlatformType.RotateY || platform.type == PlatformManager.PlatformType.RotateZ))
|
||||
{
|
||||
gDirection = -other.GetContact(0).normal;
|
||||
}
|
||||
else if (platform.type == PlatformManager.PlatformType.SpeedUp)
|
||||
{
|
||||
rb.AddForce(other.transform.forward * platform.speed * Time.deltaTime, ForceMode.Impulse);
|
||||
gDirection = -other.GetContact(0).normal;
|
||||
}
|
||||
else if (platform.type == PlatformManager.PlatformType.SpeedDown)
|
||||
{
|
||||
rb.AddForce(other.transform.forward * platform.speed * 10 * Time.deltaTime, ForceMode.Impulse);
|
||||
gDirection = -other.GetContact(0).normal;
|
||||
case PlatformManager.PlatformType.Push:
|
||||
break;
|
||||
case PlatformManager.PlatformType.Pull:
|
||||
break;
|
||||
case PlatformManager.PlatformType.RotateY:
|
||||
break;
|
||||
case PlatformManager.PlatformType.RotateZ:
|
||||
break;
|
||||
case PlatformManager.PlatformType.SpeedUp:
|
||||
rb.AddForce(other.transform.forward * platform.speed * Time.deltaTime, ForceMode.Impulse);
|
||||
break;
|
||||
case PlatformManager.PlatformType.SpeedDown:
|
||||
rb.AddForce(other.transform.forward * platform.speed * 10 * Time.deltaTime, ForceMode.Impulse);
|
||||
break;
|
||||
default:
|
||||
gDirection = -transform.up;
|
||||
break;
|
||||
}
|
||||
this.downDirection = gDirection;
|
||||
|
||||
Physics.gravity = gDirection * 9.81f;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user