Added basic bouncing

This commit is contained in:
Pasha Bibko
2026-01-13 12:19:07 +00:00
parent e235c9e440
commit c15d917245
6 changed files with 63 additions and 13 deletions

View File

@@ -1,3 +1,4 @@
using System;
using UnityEngine;
namespace InterfaceOff
@@ -7,7 +8,10 @@ namespace InterfaceOff
public WindowInteractions Interactions { get; set; }
public WindowComponents Components { get; set; }
public Vector3 Velocity { get; set; }
protected Vector3 Velocity { get; set; }
[SerializeField] private int m_FlipCooldown;
private static int MAX_FLIP_COOLDOWN = 20;
public void InstantiateWindowBase()
{
@@ -16,11 +20,22 @@ namespace InterfaceOff
OnWindowInstantiation();
}
public void LateUpdate()
private void LateUpdate()
{
if (!CanvasManager.IsRectWithinCanvas(Components.Rect) && m_FlipCooldown == 0)
{
m_FlipCooldown = MAX_FLIP_COOLDOWN;
Velocity = -Velocity;
}
transform.position += Velocity * Time.deltaTime;
}
private void FixedUpdate()
{
m_FlipCooldown = Math.Clamp(m_FlipCooldown - 1, 0, MAX_FLIP_COOLDOWN);
}
public virtual void OnWindowInstantiation() { }
public virtual void OnWindowClicked() { }
}