Files
Cielonos/Assets/Scripts/MainGame/AttackArea/Submodules/LinearDirectionMoveSubmodule.cs
SoulliesOfficial ef7b479712 initial
2025-11-25 08:19:33 -05:00

35 lines
1.3 KiB
C#

using UnityEngine;
namespace Cielonos.MainGame
{
public class LinearDirectionMoveSubmodule : MoveSubmoduleBase
{
public Vector3 direction;
public float speed;
public float acceleration;
public LinearDirectionMoveSubmodule(AttackAreaBase attackArea, Vector3 direction, float speed, float acceleration = 0,
bool overrideRotation = false, float timeScaleCoefficient = 1) : base(attackArea, timeScaleCoefficient)
{
this.direction = direction;
this.speed = speed;
this.acceleration = acceleration;
this.timeScaleCoefficient = timeScaleCoefficient;
if (overrideRotation)
{
attackArea.topParent.transform.rotation = Quaternion.LookRotation(direction);
}
}
public override void Update()
{
base.Update();
speed += acceleration * (timeScaleCoefficient * Time.deltaTime); //attackArea.creator.selfTimeModule.EntityDeltaTime);
speed = Mathf.Max(0, speed);
unscaledVelocity = direction * speed;
scaledVelocity = unscaledVelocity * timeScaleCoefficient; //attackArea.creator.selfTimeModule.EntityDeltaTime);
attackArea.topParent.transform.position += scaledVelocity * Time.deltaTime;
}
}
}