1
This commit is contained in:
39
Assets/Artists/Scripts/Equip/EquipSway.cs
Normal file
39
Assets/Artists/Scripts/Equip/EquipSway.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user