improv: better math for draggedUnits movement inheritance

This commit is contained in:
Chris
2025-10-04 00:37:07 -04:00
parent c06ed7a46a
commit 42fbffc4e5
3 changed files with 13 additions and 4 deletions

View File

@@ -1,10 +1,11 @@
using NodeCanvas.Editor; #if UNITY_EDITOR
using NodeCanvas.Editor;
using ParadoxNotion.Design; using ParadoxNotion.Design;
using Reset.Core; using Reset.Core;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
#if UNITY_EDITOR
public class BoolValueGroupDrawer : ObjectDrawer<BoolValueGroup> { public class BoolValueGroupDrawer : ObjectDrawer<BoolValueGroup> {
public override BoolValueGroup OnGUI(GUIContent _content, BoolValueGroup _instance){ public override BoolValueGroup OnGUI(GUIContent _content, BoolValueGroup _instance){
// Remove label for floats // Remove label for floats

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Reset.Core.Tools; using Reset.Core.Tools;
using Reset.Units; using Reset.Units;
using UnityEngine; using UnityEngine;
using Random = UnityEngine.Random;
public class UnitCombat : MonoBehaviour{ public class UnitCombat : MonoBehaviour{
public List<Collider> draggedUnits = new List<Collider>(); public List<Collider> draggedUnits = new List<Collider>();
@@ -14,6 +15,8 @@ public class UnitCombat : MonoBehaviour{
private float lastSpeed; private float lastSpeed;
private float speedDelta; private float speedDelta;
private float sinAmplitude;
private float sinOffset;
void Awake(){ void Awake(){
movement = GetComponent<UnitMovementHandler>(); movement = GetComponent<UnitMovementHandler>();
@@ -21,13 +24,18 @@ public class UnitCombat : MonoBehaviour{
void Start(){ void Start(){
lastPosition = transform.position; lastPosition = transform.position;
sinOffset = Random.value;
sinAmplitude = 1 + Random.value / 4f;
} }
// Update is called once per frame // Update is called once per frame
void Update(){ void Update(){
positionDelta = lastPosition.DirectionTo(transform.position); positionDelta = Vector3.Lerp(positionDelta, lastPosition.DirectionTo(transform.position), 5f * Time.deltaTime);
speedDelta = Vector3.Distance(lastPosition, transform.position) / Time.deltaTime; speedDelta = Vector3.Distance(lastPosition, transform.position) / Time.deltaTime;
float sinVal = Mathf.Sin(2f + sinOffset) * sinAmplitude;
speedDelta += sinVal;
// Test // Test
speedDelta *= 1.0f; speedDelta *= 1.0f;
speedDelta = Mathf.Max(3f, speedDelta); speedDelta = Mathf.Max(3f, speedDelta);

View File

@@ -12,7 +12,7 @@ using Unity.Netcode;
public class Player : NetworkBehaviour, IKillable{ public class Player : NetworkBehaviour, IKillable{
[HideInInspector] public PlayerControls controls; [HideInInspector] public PlayerControls controls;
[HideInInspector] public new PlayerCamera camera; [HideInInspector] public PlayerCamera camera;
float IKillable.maxHealth{ get; set; } float IKillable.maxHealth{ get; set; }
float IKillable.currentHealth{ get; set; } float IKillable.currentHealth{ get; set; }