improv: more completed melee, including support for dragging enemies along melee (rudimentary)
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Reset.Core.Tools;
|
||||
using Reset.Units;
|
||||
using UnityEngine;
|
||||
|
||||
public class UnitCombat : MonoBehaviour{
|
||||
public List<Collider> draggedUnits = new List<Collider>();
|
||||
|
||||
|
||||
private UnitMovementHandler movement;
|
||||
|
||||
private Vector3 lastPosition;
|
||||
@@ -25,7 +26,16 @@ public class UnitCombat : MonoBehaviour{
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
positionDelta = lastPosition.DirectionTo(transform.position);
|
||||
speedDelta = Vector3.Distance(lastPosition, transform.position);
|
||||
speedDelta = Vector3.Distance(lastPosition, transform.position) / Time.deltaTime;
|
||||
|
||||
// Test
|
||||
speedDelta *= 1.0f;
|
||||
speedDelta = Mathf.Max(3f, speedDelta);
|
||||
float speedDiff = Mathf.Lerp(.2f, 1.4f, speedDelta);
|
||||
speedDelta *= speedDiff;
|
||||
|
||||
DebugOverlayDrawer.ChangeValue($"Combat - {name}", "Position Delta", positionDelta);
|
||||
DebugOverlayDrawer.ChangeValue($"Combat - {name}", "Speed Delta", speedDelta);
|
||||
|
||||
lastPosition = transform.position;
|
||||
|
||||
@@ -36,9 +46,9 @@ public class UnitCombat : MonoBehaviour{
|
||||
continue;
|
||||
}
|
||||
|
||||
draggedUnitMovement.SetNewDirection((transform.rotation* positionDelta).ToVector2(), 1f, true);
|
||||
draggedUnitMovement.SetNewDirection((positionDelta).ToVector2(), 1f, true);
|
||||
draggedUnitMovement.SetNewSpeed(speedDelta, 1f, true);
|
||||
draggedUnitMovement.SetNewRotation(Quaternion.LookRotation(transform.position.DirectionTo(draggedUnit.transform.position)), 1f, true);
|
||||
draggedUnitMovement.SetNewRotation(-transform.position.DirectionTo(draggedUnit.transform.position), 1f, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
using Unity.Netcode;
|
||||
|
||||
|
||||
public class Player : NetworkBehaviour{
|
||||
[HideInInspector] public PlayerControls controls;
|
||||
[HideInInspector] public new PlayerCamera camera;
|
||||
|
||||
Reference in New Issue
Block a user