using { /Verse.org } using { /Verse.org/Native } using { /Verse.org/SceneGraph } using { /Verse.org/Simulation } using { /Verse.org/SpatialMath } using { /Verse.org/SceneGraph/KeyframedMovement } using { /UnrealEngine.com } # This is our "Recipe" for the sliding crate. # means you can see and edit these settings in the UEFN panel. slide_crates_component := class(component): # TARGET_POSITION: Where the crate wants to go. # Think of this as setting a waypoint on your map. TargetPosition: vector = <0,0,0> # SPEED: How fast it slides. # Higher number = faster. Like setting the speed of a prop-mover. Speed: float = 500.0 # DURATION: How long the slide takes. # If you don't set speed, this controls the timing. Duration: float = 2.0 # This is the magic part. We are adding the KeyframedMovement component # to this entity when it starts. OnBegin() := fun(): # Get the entity this component is attached to entity := Entity(Self) # Create a new KeyframedMovement component # This is like attaching a "Motor" to the crate movement := KeyframedMovementComponent{} # Add the motor to the crate entity.AddComponent(movement) # Now, tell the motor where to go and how fast. # We use "AddKeyframe" to set the destination. # Think of this as dropping a "Target" marker for the motor. movement.AddKeyframe( Keyframe{ Position: TargetPosition, Duration: Duration, # Easing: "EaseOut" means it starts fast and slows down at the end. # Like a car pulling into a parking spot. Easing: Easing::EaseOut } ) # Start the animation! # This tells the motor to begin moving toward the keyframe. movement.Play() # Optional: What happens when it finishes? # You could make it explode, drop loot, or disappear. OnEnd() := fun(): # For now, let's just print a message in the debug log. # Think of this as the "Announcer" speaking. print("Crate has arrived at destination!")