This commit is contained in:
haitem 2022-01-29 12:07:42 +01:00
commit 9a86c54304
9 changed files with 2058 additions and 4880 deletions

View File

@ -0,0 +1,14 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!134 &13400000
PhysicMaterial:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: PlayerMaterial
dynamicFriction: 0.6
staticFriction: 0.6
bounciness: 0
frictionCombine: 1
bounceCombine: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 055b414bc685d41409a41f4ea2d64231
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 13400000
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

1942
Assets/Scenes/Testing.unity Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 39813aced5a8ab94c8c54ad4baff2885
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1304,68 +1304,24 @@ Transform:
m_CorrespondingSourceObject: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3} m_CorrespondingSourceObject: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3}
m_PrefabInstance: {fileID: 613611969} m_PrefabInstance: {fileID: 613611969}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1001 &993189262 --- !u!1 &1172583617 stripped
PrefabInstance: GameObject:
m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 3244356566819001084, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
serializedVersion: 2 m_PrefabInstance: {fileID: 1953646381}
m_Modification:
m_TransformParent: {fileID: 327689121}
m_Modifications:
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_RootOrder
value: 12
objectReference: {fileID: 0}
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_LocalPosition.x
value: -76.9
objectReference: {fileID: 0}
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_LocalPosition.y
value: -36.7
objectReference: {fileID: 0}
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_LocalPosition.z
value: -40.016167
objectReference: {fileID: 0}
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_LocalRotation.w
value: 0.5697263
objectReference: {fileID: 0}
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_LocalRotation.z
value: 0.82183456
objectReference: {fileID: 0}
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 110.538
objectReference: {fileID: 0}
- target: {fileID: 8768991388683709947, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
propertyPath: m_Name
value: Platform_Blue (4)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
--- !u!4 &993189263 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3}
m_PrefabInstance: {fileID: 993189262}
m_PrefabAsset: {fileID: 0} 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 --- !u!4 &1210902573 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3} m_CorrespondingSourceObject: {fileID: 8768991388683709944, guid: 99c4e582c7358f346ab00dae4ae956f9, type: 3}
@ -1695,21 +1651,21 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 1608137079, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} - target: {fileID: 3244356566819001072, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: ShapeModule.angle propertyPath: m_Enabled
value: 8.8 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1608137079, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} - target: {fileID: 3244356566819001073, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: InitialModule.startColor.maxColor.b propertyPath: m_Enabled
value: 0.9056604 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1608137079, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} - target: {fileID: 3244356566819001085, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: InitialModule.startColor.maxColor.g propertyPath: m_LocalPosition.y
value: 0.9056604 value: 0.11
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1608137079, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} - target: {fileID: 3244356566819001087, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: InitialModule.startColor.maxColor.r propertyPath: m_CollisionDetection
value: 0.08116765 value: 2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3244356567786994344, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} - target: {fileID: 3244356567786994344, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_Name propertyPath: m_Name
@ -1759,17 +1715,13 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3244356567913423211, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} - target: {fileID: 3244356567913423212, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_BackGroundColor.b propertyPath: m_LocalPosition.y
value: 0 value: 0.55
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3244356567913423211, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} - target: {fileID: 3244356567913423212, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_BackGroundColor.g propertyPath: m_LocalPosition.z
value: 0 value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 3244356567913423211, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_BackGroundColor.r
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} m_SourcePrefab: {fileID: 100100000, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}

View File

@ -24,6 +24,8 @@ public class PlayerController : MonoBehaviour
private bool isGrounded = false; private bool isGrounded = false;
public bool isRunning = false; public bool isRunning = false;
private Vector3 downDirection;
private Vector3 follow = Vector3.zero; private Vector3 follow = Vector3.zero;
void Start() void Start()
@ -70,7 +72,7 @@ public class PlayerController : MonoBehaviour
{ {
if (other.gameObject.tag == "platform") if (other.gameObject.tag == "platform")
{ {
Physics.gravity = -Vector3.up * 9.81f; Physics.gravity = this.downDirection * 9.81f;
} }
} }
@ -86,12 +88,27 @@ public class PlayerController : MonoBehaviour
Vector3 axis; Vector3 axis;
float angle; float angle;
axis = Vector3.Cross(-transform.up, -other.GetContact(0).normal); axis = Vector3.Cross(-transform.up, -other.GetContact(0).normal);
if (other.GetContact(0).normal == other.transform.forward
|| other.GetContact(0).normal == -other.transform.forward
|| (
other.GetContact(0).normal != -other.transform.up
&& other.GetContact(0).normal != other.transform.up
&& other.GetContact(0).normal != -other.transform.right
&& other.GetContact(0).normal != other.transform.right
)
)
{
return;
}
Physics.gravity = this.downDirection * 9.81f;
if (platform.type == PlatformManager.PlatformType.SpeedUp) if (platform.type == PlatformManager.PlatformType.SpeedUp)
{ {
angle = Mathf.Atan2(Vector3.Magnitude(axis), Vector3.Dot(-transform.up, -other.GetContact(0).normal)); angle = Mathf.Atan2(Vector3.Magnitude(axis), Vector3.Dot(-transform.up, -other.GetContact(0).normal));
transform.RotateAround(axis, angle); transform.RotateAround(axis, angle);
// TODO: Rotate gravity to the center of platform
} }
// TODO: Handle other PlatformTypes
Physics.gravity = this.downDirection * 9.81f;
} }
@ -100,6 +117,18 @@ public class PlayerController : MonoBehaviour
isGrounded = true; isGrounded = true;
if (other.gameObject.tag == "platform") if (other.gameObject.tag == "platform")
{ {
if (other.GetContact(0).normal == other.transform.forward
|| other.GetContact(0).normal == -other.transform.forward
|| (
other.GetContact(0).normal != -other.transform.up
&& other.GetContact(0).normal != other.transform.up
&& other.GetContact(0).normal != -other.transform.right
&& other.GetContact(0).normal != other.transform.right
)
)
{
return;
}
Vector3 axis; Vector3 axis;
float angle; float angle;
@ -114,6 +143,8 @@ public class PlayerController : MonoBehaviour
PlatformManager platform = other.gameObject.GetComponent<PlatformManager>(); PlatformManager platform = other.gameObject.GetComponent<PlatformManager>();
gDirection = -transform.up; gDirection = -transform.up;
if (platform == null){ if (platform == null){
// FIXME: remove
this.downDirection = -transform.up;
return; return;
} }
if (platform.type == PlatformManager.PlatformType.Pull) if (platform.type == PlatformManager.PlatformType.Pull)
@ -138,6 +169,7 @@ public class PlayerController : MonoBehaviour
rb.AddForce(other.transform.forward * platform.speed * 10 * Time.deltaTime, ForceMode.Impulse); rb.AddForce(other.transform.forward * platform.speed * 10 * Time.deltaTime, ForceMode.Impulse);
gDirection = -transform.up; gDirection = -transform.up;
} }
this.downDirection = gDirection;
Physics.gravity = gDirection * 9.81f; Physics.gravity = gDirection * 9.81f;
} }

View File

@ -8,9 +8,9 @@ public class UiController : MonoBehaviour
public GameObject player = null; public GameObject player = null;
private Vector3 startPosition; private Vector3 startPosition;
private Vector3 playerPosition; private Vector3 playerPosition;
public TextMeshProUGUI uiDistance; public TextMeshProUGUI uiDistance;
public float distance = 0.0f; public float distance = 0.0f;
private float oldDistance = 0.0f;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
@ -23,6 +23,10 @@ public class UiController : MonoBehaviour
{ {
playerPosition = this.player.transform.position; playerPosition = this.player.transform.position;
distance = Vector3.Distance(this.startPosition, this.playerPosition); distance = Vector3.Distance(this.startPosition, this.playerPosition);
if (oldDistance < distance)
{
uiDistance.text = "Score : " + distance.ToString("0"); uiDistance.text = "Score : " + distance.ToString("0");
oldDistance = distance;
}
} }
} }

View File

@ -6,10 +6,10 @@ EditorUserSettings:
serializedVersion: 4 serializedVersion: 4
m_ConfigSettings: m_ConfigSettings:
RecentlyUsedSceneGuid-0: RecentlyUsedSceneGuid-0:
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a value: 5b53500307070b0b0b0f5a2648735a4412154f737d2b2536782f1e32e0b86c3a
flags: 0 flags: 0
RecentlyUsedSceneGuid-1: RecentlyUsedSceneGuid-1:
value: 5b53500307070b0b0b0f5a2648735a4412154f737d2b2536782f1e32e0b86c3a value: 50080c5756540a5e095b0d7a11210644154f1b7f782922642f281b35b0b86c6d
flags: 0 flags: 0
RecentlyUsedScenePath-0: RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d