droplet script
This commit is contained in:
@@ -14,7 +14,7 @@ GameObject:
|
||||
- component: {fileID: 5321372118810808216}
|
||||
m_Layer: 0
|
||||
m_Name: Branch
|
||||
m_TagString: Untagged
|
||||
m_TagString: Platform
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
|
||||
@@ -105,7 +105,7 @@ GameObject:
|
||||
- component: {fileID: 1462837664068369080}
|
||||
m_Layer: 0
|
||||
m_Name: LeaveObstacle
|
||||
m_TagString: Untagged
|
||||
m_TagString: Platform
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ GameObject:
|
||||
- component: {fileID: 1230605949537068183}
|
||||
m_Layer: 0
|
||||
m_Name: RealBranch 1
|
||||
m_TagString: Untagged
|
||||
m_TagString: Platform
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
|
||||
@@ -14,7 +14,7 @@ GameObject:
|
||||
- component: {fileID: 1230605949537068183}
|
||||
m_Layer: 0
|
||||
m_Name: RealBranch
|
||||
m_TagString: Untagged
|
||||
m_TagString: Platform
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using Object = System.Object;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class DamageHandler : MonoBehaviour
|
||||
@@ -60,6 +59,11 @@ public class DamageHandler : MonoBehaviour
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D other)
|
||||
{
|
||||
|
||||
if (other.collider.CompareTag("Minidrop")){
|
||||
UpdateHealth(0.2f);
|
||||
}
|
||||
//on collision check fall damage
|
||||
float fallSpeed = lastYVelocity;
|
||||
if (fallSpeed < -threshold)
|
||||
{
|
||||
@@ -72,6 +76,8 @@ public class DamageHandler : MonoBehaviour
|
||||
public void UpdateHealth(float health)
|
||||
{
|
||||
this.health = health;
|
||||
if (health > maxHealth) this.health = maxHealth;
|
||||
|
||||
Transform transform = GetComponent<Transform>();
|
||||
float healthScaling = minSize + (1 - minSize) * (this.health / maxHealth);
|
||||
//adjust size based on health
|
||||
|
||||
@@ -8,7 +8,7 @@ public class DropletMovement : MonoBehaviour
|
||||
private Collider2D characterCollider;
|
||||
|
||||
// helper variables
|
||||
private bool isGrounded = true;
|
||||
private bool isGrounded = false;
|
||||
private float facingDirection = 1f;
|
||||
private bool isDropping = false;
|
||||
private float fallTimer;
|
||||
@@ -40,7 +40,7 @@ public class DropletMovement : MonoBehaviour
|
||||
{
|
||||
|
||||
//dashing
|
||||
if (isDashing)
|
||||
if (isDashing || isGrounded == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -93,18 +93,15 @@ public class DropletMovement : MonoBehaviour
|
||||
if (isDashing || isDropping)
|
||||
{
|
||||
return;
|
||||
} // was here before
|
||||
}
|
||||
|
||||
//wind
|
||||
float windForce = 0f;
|
||||
|
||||
if (WindManager.Instance != null)
|
||||
{
|
||||
windForce = WindManager.Instance.CurrentWindForce;
|
||||
}
|
||||
|
||||
rb.linearVelocity = new Vector2(movement.x * moveSpeed + windForce, rb.linearVelocity.y);
|
||||
|
||||
//used to be rb.linearVelocity = new Vector2(movement.x * moveSpeed, rb.linearVelocity.y);
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
@@ -151,9 +148,24 @@ public class DropletMovement : MonoBehaviour
|
||||
}
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D col)
|
||||
{
|
||||
if (col.collider.CompareTag("Platform") && rb.linearVelocity.y == 0)
|
||||
{
|
||||
isGrounded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isGrounded = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionExit2D(Collision2D collision)
|
||||
{
|
||||
if (collision.collider.CompareTag("Platform"))
|
||||
{
|
||||
isGrounded = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void DropDown()
|
||||
|
||||
@@ -7,6 +7,7 @@ TagManager:
|
||||
- Border
|
||||
- Hole
|
||||
- Minidrop
|
||||
- Platform
|
||||
layers:
|
||||
- Default
|
||||
- TransparentFX
|
||||
|
||||
Reference in New Issue
Block a user