Merge branch 'main' of https://github.com/orsolya-st/gamejam_050626
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bc8547deda124e4418a491921dad1ff9
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -30,16 +30,15 @@ public class DropletMovement : MonoBehaviour
|
|||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//dashing
|
||||||
if (isDashing)
|
if (isDashing)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
movement.x = Input.GetAxisRaw("Horizontal");
|
movement.x = Input.GetAxisRaw("Horizontal");
|
||||||
|
|
||||||
if (movement.x < 0) facingDirection = -1;
|
if (movement.x < 0) facingDirection = -1;
|
||||||
if (movement.x > 0) facingDirection = 1;
|
if (movement.x > 0) facingDirection = 1;
|
||||||
|
|
||||||
if (isGrounded &&
|
if (isGrounded &&
|
||||||
(Input.GetKeyDown(KeyCode.Space) ||
|
(Input.GetKeyDown(KeyCode.Space) ||
|
||||||
Input.GetKeyDown(KeyCode.UpArrow) ||
|
Input.GetKeyDown(KeyCode.UpArrow) ||
|
||||||
@@ -47,11 +46,18 @@ public class DropletMovement : MonoBehaviour
|
|||||||
{
|
{
|
||||||
rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpingPower);
|
rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpingPower);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.LeftShift) && canDash)
|
if (Input.GetKeyDown(KeyCode.LeftShift) && canDash)
|
||||||
{
|
{
|
||||||
StartCoroutine(Dash());
|
StartCoroutine(Dash());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//dropdown
|
||||||
|
if (!isGrounded){return;}
|
||||||
|
if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S))
|
||||||
|
{
|
||||||
|
DropDown();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
@@ -103,4 +109,40 @@ public class DropletMovement : MonoBehaviour
|
|||||||
{
|
{
|
||||||
isGrounded = false;
|
isGrounded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DropDown()
|
||||||
|
{
|
||||||
|
//when "s" or "down key" is pressed turn of/disable collider;
|
||||||
|
//move object slowly down (1 seconds, move down the height of the collision box)
|
||||||
|
//after that enable collider again
|
||||||
|
|
||||||
|
if (isGrounded && (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow)))
|
||||||
|
{
|
||||||
|
StartCoroutine(DropRoutine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator DropRoutine()
|
||||||
|
{
|
||||||
|
Collider2D playerCollider = GetComponent<Collider2D>();
|
||||||
|
|
||||||
|
playerCollider.isTrigger = true;
|
||||||
|
|
||||||
|
float duration = 1f;
|
||||||
|
float elapsed = 0f; //measure time
|
||||||
|
|
||||||
|
//move down the height of the collider
|
||||||
|
float dropDistance = playerCollider.bounds.size.y;
|
||||||
|
float speed = dropDistance/duration;
|
||||||
|
|
||||||
|
while (elapsed < duration)
|
||||||
|
{
|
||||||
|
transform.Translate(Vector3.down * speed * Time.deltaTime);
|
||||||
|
elapsed += Time.deltaTime; //update time
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//enable collider --> not a trigger anymore
|
||||||
|
playerCollider.isTrigger = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user