Skip to content

Instantly share code, notes, and snippets.

@ykafia
Last active December 16, 2021 15:27
Show Gist options
  • Save ykafia/371b310de1ba7bb8ab3d2feffce2a190 to your computer and use it in GitHub Desktop.
Save ykafia/371b310de1ba7bb8ab3d2feffce2a190 to your computer and use it in GitHub Desktop.
using Stride.Core.Mathematics;
using Stride.Engine;
using Stride.Input;
namespace SomeNameSpace
{
public class CameraFollow : SyncScript
{
public float DelaySpeed = 0.6f;
public Vector3 Offset = new(-1, 1, 0);
private float distance = 5;
public Entity Character;
public override void Start()
{
Entity.Transform.Position = Character.Transform.Position + Offset * distance;
}
public override void Update()
{
var pos = Entity.Transform.Position;
var targetPos = chrPos + Offset * distance;
var smoothPos = Vector3.Lerp(pos, targetPos, DelaySpeed);
Entity.Transform.Position = smoothPos;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment