Last active
June 12, 2025 14:19
-
-
Save ykafia/371b310de1ba7bb8ab3d2feffce2a190 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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