projectboost/scenes/MovingHazard.cs
2025-02-09 12:05:53 +01:00

20 lines
560 B
C#

using Godot;
using System;
public partial class MovingHazard : AnimatableBody3D
{
[Export]
public Vector3 destination;
[Export(PropertyHint.Range, "0.0, 10.0")]
public float duration = 1.0f;
public override void _Ready()
{
Tween tween = CreateTween();
tween.SetLoops();
tween.SetTrans(Tween.TransitionType.Sine);
tween.TweenProperty(this, "global_position", GlobalPosition + destination, duration);
tween.TweenProperty(this, "global_position", GlobalPosition - destination, duration);
}
}