Effects/GyroscopicFollower.cs
namespace PlanetMeat;
[Group( "Planet Meat - Effects" ), Title( "Gyroscopic Follower" ), Icon( "video_stable" )]
public sealed class GyroscopicFollower : Component
{
[Property] public bool MatchPitch { get; set; } = false;
[Property] public bool MatchYaw { get; set; } = false;
[Property] public bool MatchRoll { get; set; } = false;
[Property] public GameObject Follow { get; set; }
private Angles startAngles { get; set; }
protected override void OnStart()
{
base.OnStart();
startAngles = WorldRotation;
}
protected override void OnUpdate()
{
base.OnUpdate();
var f = Follow.WorldRotation.Angles();
WorldRotation = new Angles(
MatchPitch ? f.pitch : startAngles.pitch,
MatchYaw ? f.yaw : startAngles.yaw,
MatchRoll ? f.roll : startAngles.roll
);
}
}