maint: renamed player folder to units to match namespaces. added unit class as well.

This commit is contained in:
Chris
2025-10-04 01:05:37 -04:00
parent a80d1d487e
commit af0aab450b
38 changed files with 22 additions and 6 deletions

View File

@@ -30,23 +30,33 @@ public class UnitCombat : MonoBehaviour{
// Update is called once per frame
void Update(){
DragAttackedUnits();
}
void DragAttackedUnits(){
// Get the original difference in position for speed and direction
positionDelta = Vector3.Lerp(positionDelta, lastPosition.DirectionTo(transform.position), 5f * Time.deltaTime);
speedDelta = Vector3.Distance(lastPosition, transform.position) / Time.deltaTime;
// Add some randomness to the movements based on small offsets
float sinVal = Mathf.Sin(2f + sinOffset) * sinAmplitude;
speedDelta += sinVal;
// Test
speedDelta *= 1.0f;
// Set a floor to prevent them from not moving enough
speedDelta = Mathf.Max(3f, speedDelta);
// Multiply the speed to be lower when further, and faster when close
float speedDiff = Mathf.Lerp(.2f, 1.4f, speedDelta);
speedDelta *= speedDiff;
// Debug
DebugOverlayDrawer.ChangeValue($"Combat - {name}", "Position Delta", positionDelta);
DebugOverlayDrawer.ChangeValue($"Combat - {name}", "Speed Delta", speedDelta);
// Update last known position
lastPosition = transform.position;
// Apply the speed, direction, and rotation to each unit
foreach (Collider draggedUnit in draggedUnits) {
UnitMovementHandler draggedUnitMovement = draggedUnit.GetComponent<UnitMovementHandler>();
if (!draggedUnitMovement) {

View File

@@ -10,9 +10,8 @@ using Sirenix.OdinInspector;
using Sirenix.Serialization;
using Unity.Netcode;
public class Player : NetworkBehaviour, IKillable{
public class Player : Unit, IKillable{
[HideInInspector] public PlayerControls controls;
[HideInInspector] public PlayerCamera camera;
float IKillable.maxHealth{ get; set; }
float IKillable.currentHealth{ get; set; }
@@ -89,4 +88,4 @@ public class Player : NetworkBehaviour, IKillable{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,4 @@
using Unity.Netcode;
public class Unit : NetworkBehaviour{
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d9f5c0c9bf384882925c15b3c93fff1b
timeCreated: 1759554015