droplet script

This commit is contained in:
orsolya-st
2026-06-06 17:28:30 +02:00
parent 9c29e3d9b1
commit 87c5b927b5
7 changed files with 35 additions and 16 deletions
+1 -1
View File
@@ -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
+9 -3
View File
@@ -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)
{
@@ -70,8 +74,10 @@ 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
+21 -9
View File
@@ -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;
}
@@ -91,20 +91,17 @@ public class DropletMovement : MonoBehaviour
private void FixedUpdate()
{
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,8 +148,23 @@ 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)
{
isGrounded = true;
if (collision.collider.CompareTag("Platform"))
{
isGrounded = false;
}
}
+1
View File
@@ -7,6 +7,7 @@ TagManager:
- Border
- Hole
- Minidrop
- Platform
layers:
- Default
- TransparentFX