namespacify everything
This commit is contained in:
@@ -1,75 +1,74 @@
|
||||
using FlaxEngine;
|
||||
|
||||
namespace Game
|
||||
namespace Game;
|
||||
|
||||
public class CameraSpring : Script
|
||||
{
|
||||
public class CameraSpring : Script
|
||||
private bool lastGround;
|
||||
private Float3 lastPosition;
|
||||
public float percY;
|
||||
|
||||
private Actor playerActor;
|
||||
private PlayerMovement playerMovement;
|
||||
|
||||
public float speed = 240f;
|
||||
private Float3 targetOffset;
|
||||
private Actor viewModelHolder;
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
private bool lastGround;
|
||||
private Float3 lastPosition;
|
||||
public float percY;
|
||||
playerActor = Actor.Parent.Parent;
|
||||
playerMovement = playerActor.GetScript<PlayerMovement>();
|
||||
viewModelHolder = playerActor.GetChild("ViewModelHolder");
|
||||
|
||||
private Actor playerActor;
|
||||
private PlayerMovement playerMovement;
|
||||
lastGround = playerMovement.OnGround;
|
||||
targetOffset = Actor.LocalPosition;
|
||||
}
|
||||
|
||||
public float speed = 240f;
|
||||
private Float3 targetOffset;
|
||||
private Actor viewModelHolder;
|
||||
private void UpdatePosition(Float3 position)
|
||||
{
|
||||
Actor.Position = position;
|
||||
viewModelHolder.Position = position;
|
||||
}
|
||||
|
||||
public override void OnStart()
|
||||
public override void OnUpdate()
|
||||
{
|
||||
Float3 position = Actor.Parent.Position + targetOffset;
|
||||
Float3 targetPosition = position;
|
||||
|
||||
if (playerMovement.OnGround)
|
||||
{
|
||||
playerActor = Actor.Parent.Parent;
|
||||
playerMovement = playerActor.GetScript<PlayerMovement>();
|
||||
viewModelHolder = playerActor.GetChild("ViewModelHolder");
|
||||
|
||||
lastGround = playerMovement.OnGround;
|
||||
targetOffset = Actor.LocalPosition;
|
||||
}
|
||||
|
||||
private void UpdatePosition(Float3 position)
|
||||
{
|
||||
Actor.Position = position;
|
||||
viewModelHolder.Position = position;
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
Float3 position = Actor.Parent.Position + targetOffset;
|
||||
Float3 targetPosition = position;
|
||||
|
||||
if (playerMovement.OnGround)
|
||||
float deltaY = position.Y - lastPosition.Y;
|
||||
//if (Mathf.Abs(deltaY) < 10f)
|
||||
if (deltaY > 0)
|
||||
{
|
||||
float deltaY = position.Y - lastPosition.Y;
|
||||
//if (Mathf.Abs(deltaY) < 10f)
|
||||
if (deltaY > 0)
|
||||
if (deltaY > 100f)
|
||||
{
|
||||
if (deltaY > 100f)
|
||||
{
|
||||
// Teleported, snap instantly
|
||||
UpdatePosition(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
const float catchUpDistance = 10f;
|
||||
const float catchUpMinMultip = 0.25f;
|
||||
percY = Mathf.Abs(deltaY) / catchUpDistance;
|
||||
percY = Mathf.Min(1.0f, percY + catchUpMinMultip);
|
||||
percY *= percY;
|
||||
// Teleported, snap instantly
|
||||
UpdatePosition(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
const float catchUpDistance = 10f;
|
||||
const float catchUpMinMultip = 0.25f;
|
||||
percY = Mathf.Abs(deltaY) / catchUpDistance;
|
||||
percY = Mathf.Min(1.0f, percY + catchUpMinMultip);
|
||||
percY *= percY;
|
||||
|
||||
float adjustSpeed = speed * Time.DeltaTime * percY;
|
||||
float adjustSpeed = speed * Time.DeltaTime * percY;
|
||||
|
||||
position.Y = lastPosition.Y; //-= deltaY;
|
||||
position.Y = Mathf.MoveTowards(position.Y, targetPosition.Y, adjustSpeed);
|
||||
UpdatePosition(position);
|
||||
}
|
||||
position.Y = lastPosition.Y; //-= deltaY;
|
||||
position.Y = Mathf.MoveTowards(position.Y, targetPosition.Y, adjustSpeed);
|
||||
UpdatePosition(position);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePosition(position);
|
||||
}
|
||||
|
||||
lastPosition = position;
|
||||
lastGround = playerMovement.OnGround;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePosition(position);
|
||||
}
|
||||
|
||||
lastPosition = position;
|
||||
lastGround = playerMovement.OnGround;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user