This commit is contained in:
CortexCore
2023-09-01 14:33:54 +08:00
parent 4fadd3a530
commit 8ef5c7ec0a
451 changed files with 1048940 additions and 2028 deletions

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit;
using BITKit.Entities;
using UnityEngine;
using UnityEngine.InputSystem;
namespace BITFALL.Player.Movement
{
public class EquipSway : EntityComponent
{
[SerializeField] private float rotDelta;
[SerializeField] private float rotValue;
[SerializeField] private float posDelta;
[SerializeField] private float posValue;
[SerializeField] private LocationAdditive locationAdditive;
private Quaternion currentRotation;
private Vector3 currentPosition;
private IEntityMovement _movement;
public override void OnAwake()
{
_movement = entity.Get<IEntityMovement>();
}
public override void OnLateUpdate(float deltaTime)
{
var velocity = _movement.LocomotionBasedVelocity;
var angularVelocity = _movement.AngularVelocity;
currentPosition = Vector3.Lerp(currentPosition,velocity * posValue,posDelta * deltaTime);
currentRotation = Quaternion.Lerp(currentRotation,Quaternion.Euler(angularVelocity * rotValue),rotDelta * deltaTime);
locationAdditive.AddEuler(currentRotation.eulerAngles);
locationAdditive.AddPosition(currentPosition);
}
}
}