This commit is contained in:
cemt1363
2026-06-06 17:30:53 +02:00
9 changed files with 48 additions and 37 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
+3 -3
View File
@@ -16,7 +16,7 @@ GameObject:
- component: {fileID: 8211840801622381919}
m_Layer: 0
m_Name: MiniDroplet
m_TagString: Untagged
m_TagString: Minidrop
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -140,7 +140,7 @@ Animation:
m_GameObject: {fileID: 3724115605263402928}
m_Enabled: 1
serializedVersion: 4
m_Animation: {fileID: 0}
m_Animation: {fileID: 7400000, guid: e4158635e9083d84b8d27001bfbda9b7, type: 2}
m_Animations: []
m_WrapMode: 0
m_PlayAutomatically: 1
@@ -157,7 +157,7 @@ Animator:
m_GameObject: {fileID: 3724115605263402928}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 3bbead65504fbb048ac08d62468d0776, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 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
+14 -15
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections;
using UnityEngine;
using Object = System.Object;
using UnityEngine.SceneManagement;
public class DamageHandler : MonoBehaviour
@@ -26,11 +25,11 @@ public class DamageHandler : MonoBehaviour
private void Start()
{
threshold = 10f;
multiplier = 0.1f;
threshold = 10f;
multiplier = 0.1f;
maxHealth = 1f;
minSize = 0.8f;
maxHealth = 1f;
minSize = 0.8f;
health = maxHealth;
}
@@ -60,32 +59,32 @@ 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)
{
float fallDamage = (-fallSpeed - threshold) * multiplier;
// Debug.Log($"Fell with velocity:{fallSpeed}. Fall damage{fallDamage}");
UpdateHealth(health - fallDamage);
// Debug.Log($"New health:{health - fallDamage}");
}
else
{
// Debug.Log($"Fell with velocity:{fallSpeed}. No fall damage");
}
}
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
transform.localScale = new Vector3(healthScaling,healthScaling,healthScaling);
// Debug.Log("UpdatedScale and health");
if(this.health <= 0f)
{
// Debug.Log("Die");
Die();
}
}
+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;
}
}
+4 -6
View File
@@ -2,15 +2,13 @@ using UnityEngine;
public class MiniDroplet : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
float size = Random.Range(0.3f, 0.7f);
Vector2 targetSize = new Vector2(size, size);
// Update is called once per frame
void Update()
{
transform.localScale = targetSize;
}
}
+2
View File
@@ -6,6 +6,8 @@ TagManager:
tags:
- Border
- Hole
- Minidrop
- Platform
layers:
- Default
- TransparentFX