improv: better math for draggedUnits movement inheritance
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
using NodeCanvas.Editor;
|
||||
#if UNITY_EDITOR
|
||||
using NodeCanvas.Editor;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
public class BoolValueGroupDrawer : ObjectDrawer<BoolValueGroup> {
|
||||
public override BoolValueGroup OnGUI(GUIContent _content, BoolValueGroup _instance){
|
||||
// Remove label for floats
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using Reset.Core.Tools;
|
||||
using Reset.Units;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class UnitCombat : MonoBehaviour{
|
||||
public List<Collider> draggedUnits = new List<Collider>();
|
||||
@@ -14,6 +15,8 @@ public class UnitCombat : MonoBehaviour{
|
||||
|
||||
private float lastSpeed;
|
||||
private float speedDelta;
|
||||
private float sinAmplitude;
|
||||
private float sinOffset;
|
||||
|
||||
void Awake(){
|
||||
movement = GetComponent<UnitMovementHandler>();
|
||||
@@ -21,12 +24,17 @@ public class UnitCombat : MonoBehaviour{
|
||||
|
||||
void Start(){
|
||||
lastPosition = transform.position;
|
||||
sinOffset = Random.value;
|
||||
sinAmplitude = 1 + Random.value / 4f;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
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;
|
||||
|
||||
float sinVal = Mathf.Sin(2f + sinOffset) * sinAmplitude;
|
||||
speedDelta += sinVal;
|
||||
|
||||
// Test
|
||||
speedDelta *= 1.0f;
|
||||
|
||||
@@ -12,7 +12,7 @@ using Unity.Netcode;
|
||||
|
||||
public class Player : NetworkBehaviour, IKillable{
|
||||
[HideInInspector] public PlayerControls controls;
|
||||
[HideInInspector] public new PlayerCamera camera;
|
||||
[HideInInspector] public PlayerCamera camera;
|
||||
|
||||
float IKillable.maxHealth{ get; set; }
|
||||
float IKillable.currentHealth{ get; set; }
|
||||
|
||||
Reference in New Issue
Block a user