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_PrefabInstance: {fileID: 613611969}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &993189262
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
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}
--- !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}
@ -1695,21 +1651,21 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1608137079, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: ShapeModule.angle
value: 8.8
- target: {fileID: 3244356566819001072, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1608137079, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: InitialModule.startColor.maxColor.b
value: 0.9056604
- target: {fileID: 3244356566819001073, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1608137079, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: InitialModule.startColor.maxColor.g
value: 0.9056604
- target: {fileID: 3244356566819001085, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_LocalPosition.y
value: 0.11
objectReference: {fileID: 0}
- target: {fileID: 1608137079, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: InitialModule.startColor.maxColor.r
value: 0.08116765
- target: {fileID: 3244356566819001087, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_CollisionDetection
value: 2
objectReference: {fileID: 0}
- target: {fileID: 3244356567786994344, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_Name
@ -1759,17 +1715,13 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3244356567913423211, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_BackGroundColor.b
value: 0
- target: {fileID: 3244356567913423212, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_LocalPosition.y
value: 0.55
objectReference: {fileID: 0}
- target: {fileID: 3244356567913423211, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_BackGroundColor.g
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3244356567913423211, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_BackGroundColor.r
value: 0
- target: {fileID: 3244356567913423212, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_LocalPosition.z
value: 0.5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}

View File

@ -24,6 +24,8 @@ public class PlayerController : MonoBehaviour
private bool isGrounded = false;
public bool isRunning = false;
private Vector3 downDirection;
private Vector3 follow = Vector3.zero;
void Start()
@ -70,7 +72,7 @@ public class PlayerController : MonoBehaviour
{
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;
float angle;
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)
{
angle = Mathf.Atan2(Vector3.Magnitude(axis), Vector3.Dot(-transform.up, -other.GetContact(0).normal));
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;
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;
float angle;
@ -114,6 +143,8 @@ public class PlayerController : MonoBehaviour
PlatformManager platform = other.gameObject.GetComponent<PlatformManager>();
gDirection = -transform.up;
if (platform == null){
// FIXME: remove
this.downDirection = -transform.up;
return;
}
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);
gDirection = -transform.up;
}
this.downDirection = gDirection;
Physics.gravity = gDirection * 9.81f;
}

View File

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

View File

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