mirror of
https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
synced 2025-06-27 11:58:51 +02:00
feat: able to jump on obstacle
This commit is contained in:
@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e105dbba5bf85a944a8270ed72ebd3d2
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Obstacle : MonoBehaviour
|
||||
public class ObstacleKiller : MonoBehaviour
|
||||
{
|
||||
public PlayerScript playerScript;
|
||||
public GameObject playerObject;
|
||||
@ -19,5 +19,6 @@ public class Obstacle : MonoBehaviour
|
||||
{
|
||||
playerObject.transform.rotation = playerScript.initialRotation;
|
||||
playerObject.transform.position = playerScript.initialPosition;
|
||||
playerScript.isColliding = false;
|
||||
}
|
||||
}
|
2
Assets/Scripts/ObstacleKiller.cs.meta
Normal file
2
Assets/Scripts/ObstacleKiller.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ad4baca6c852a00b8bf21afdd5fba8c
|
27
Assets/Scripts/ObstacleSafe.cs
Normal file
27
Assets/Scripts/ObstacleSafe.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ObstacleSafe : MonoBehaviour
|
||||
{
|
||||
public PlayerScript playerScript;
|
||||
public GameObject playerObject;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScript>();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnCollisionEnter()
|
||||
{
|
||||
playerScript.isColliding = true;
|
||||
}
|
||||
|
||||
public void OnCollisionExit()
|
||||
{
|
||||
playerScript.isColliding = false;
|
||||
}
|
||||
}
|
2
Assets/Scripts/ObstacleSafe.cs.meta
Normal file
2
Assets/Scripts/ObstacleSafe.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 982954923c829c546bed40ee7f6b946a
|
@ -11,6 +11,7 @@ public class PlayerScript : MonoBehaviour
|
||||
public ParticleSystem particle;
|
||||
|
||||
private bool wantsToJump = false;
|
||||
public bool isColliding = true;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
@ -66,7 +67,8 @@ public class PlayerScript : MonoBehaviour
|
||||
|
||||
private bool IsJumping()
|
||||
{
|
||||
return Mathf.Abs(initialPosition.y - transform.position.y) > 0.05f;
|
||||
// return Mathf.Abs(initialPosition.y - transform.position.y) > 0.05f;
|
||||
return !isColliding;
|
||||
}
|
||||
|
||||
private void AlignRotation()
|
||||
|
@ -19,5 +19,6 @@ public class SpikeScript : MonoBehaviour
|
||||
{
|
||||
playerObject.transform.rotation = playerScript.initialRotation;
|
||||
playerObject.transform.position = playerScript.initialPosition;
|
||||
playerScript.isColliding = false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user