### Spawning and Managing Particle Systems in Verse Source: https://context7.com/vz-creates/uefn/llms.txt Demonstrates how to spawn particle systems at specified locations with optional rotation and start delay. It also shows how to cancel a particle effect. Requires external particle system assets and uses spatial math for positioning and rotation. ```verse using { /UnrealEngine.com/Assets } using { /UnrealEngine.com/Temporary/SpatialMath } using { /Verse.org/Assets } using { /Verse.org/SpatialMath } # Particle system asset ExplosionParticle: particle_system = external {} TrailParticle: particle_system = external {} SpawnEffects(Location: vector3): void = # Spawn particle with temporary spatial math vector TempRotation := MakeRotationFromYawPitchRollDegrees(0.0, 0.0, 0.0) Effect1 := SpawnParticleSystem( ExplosionParticle, Location, Rotation := option{TempRotation}, StartDelay := option{0.5} ) # Spawn particle with Verse spatial math vector VerseLocation := vector3{X := 0.0, Y := 0.0, Z := 100.0} VerseRotation := rotation{Axis := vector3{X := 0.0, Y := 0.0, Z := 1.0}, Angle := 0.0} Effect2 := SpawnParticleSystem( TrailParticle, VerseLocation, Rotation := option{VerseRotation}, StartDelay := option{1.0} ) # Cancel particle effect Effect1.Cancel() ``` -------------------------------- ### Manage Item Properties with Item Component Source: https://context7.com/vz-creates/uefn/llms.txt Demonstrates how to set and modify stack size, subscribe to item events, check and change equipment state, take items from a stack, drop items, and get the parent inventory. It also includes handlers for stack size, equipment, and inventory change events. ```Verse using { /UnrealEngine.com/Itemization } ManageItem(ItemEntity: entity): void = if (ItemComp := ItemEntity.GetComponent[item_component]): # Set and modify stack size ItemComp.SetStackSize(5) ItemComp.SetMaxStackSize(99, ClampStackSize := true) # Subscribe to item events ItemComp.ChangeStackSizeEvent.Subscribe(OnStackSizeChanged) ItemComp.ChangeEquippedEvent.Subscribe(OnEquippedStateChanged) ItemComp.ChangeInventoryEvent.Subscribe(OnInventoryChanged) # Check if item is equipped if (ItemComp.IsEquipped[]): Print("Item is equipped") # Unequip the item case (ItemComp.Unequip[]): result(Success, _) => Print("Successfully unequipped") result(_, Errors) => Print("Failed to unequip: {Errors.Length} errors") else: # Equip the item case (ItemComp.Equip[]): result(Success, _) => Print("Successfully equipped") result(_, Errors) => Print("Failed to equip: {Errors.Length} errors") # Take items from stack if (TakenItem := ItemComp.Take[3]): Print("Took 3 items from stack") # Drop item into world ItemComp.Drop[] # Get parent inventory if (ParentInv := ItemComp.GetParentInventory[]): Print("Item is in an inventory") OnStackSizeChanged(Result: change_stack_size_result): void = Print("Stack size changed") OnEquippedStateChanged(Result: change_equipped_result): void = Print("Equipment state changed") OnInventoryChanged(Result: change_inventory_result): void = Print("Item moved to different inventory") ``` -------------------------------- ### NPC Perception: Setup and Event Handling Source: https://context7.com/vz-creates/uefn/llms.txt Sets up the NPC perception system to detect targets via sight, hearing, and touch. It subscribes to various detection events (TargetSeenEvent, TargetHeardEvent, TargetTouchedEvent, TargetRemovedEvent) and includes callback functions for each. The system can also check currently detected targets and their line of sight. Dependencies include Fortnite.com/AI and Verse.org/Simulation. Outputs are print statements indicating detected targets and their status. ```verse using { /Fortnite.com/AI } using { /Verse.org/Simulation } SetupNPCPerception(Character: fort_character): void = if (Perception := Character.GetFortNPCPerception[]): # Subscribe to target detection events Perception.TargetSeenEvent.Subscribe(OnTargetSeen) Perception.TargetHeardEvent.Subscribe(OnTargetHeard) Perception.TargetTouchedEvent.Subscribe(OnTargetTouched) Perception.TargetRemovedEvent.Subscribe(OnTargetRemoved) # Check all detected targets for (TargetInfo : Perception.DetectedTargets): if (TargetInfo.HasLineOfSight?): Print("Target has line of sight") LastKnownPos := Perception.GetLastKnownPosition[TargetInfo.Target] OnTargetSeen(TargetInfo: fort_target_info): void = case (TargetInfo.Attitude): team_attitude.Friendly => Print("Friendly target seen") team_attitude.Hostile => Print("Enemy target seen") team_attitude.Neutral => Print("Neutral target seen") OnTargetHeard(TargetInfo: fort_target_info): void = Print("Sound detected from target") OnTargetTouched(TargetInfo: fort_target_info): void = Print("Physical contact with target") OnTargetRemoved(Target: entity): void = Print("Target no longer detected") ``` -------------------------------- ### Managing Sidekick Behavior and Events in Verse Source: https://context7.com/vz-creates/uefn/llms.txt Provides functionality to manage player-owned sidekicks, including getting the owner, subscribing to mood changes, checking current mood, overriding mood, and playing/subscribing to reaction events. Requires the equipped sidekick component and uses AI and simulation modules. ```verse using { /Fortnite.com/AI } using { /Verse.org/Simulation } ManageSidekick(SidekickEntity: entity): void = if (SidekickComp := SidekickEntity.GetComponent[equipped_sidekick_component]): # Get owning agent if (Owner := SidekickComp.GetOwningAgent[]): Print("Sidekick owner: {Owner}") # Subscribe to mood changes SidekickComp.ChangeMoodEvent.Subscribe(OnSidekickMoodChanged) # Get current mood CurrentMood := SidekickComp.GetMood() case (CurrentMood): sidekick_mood.Neutral => Print("Sidekick is neutral") sidekick_mood.Combat => Print("Sidekick is in combat") sidekick_mood.Worried => Print("Sidekick is worried") sidekick_mood.Bored => Print("Sidekick is bored") # Override mood set SidekickComp.MoodOverride = option{sidekick_mood.Happy} # Play reaction SidekickComp.PlayReaction[sidekick_reaction.Dance] SidekickComp.PlayReaction[sidekick_reaction.Angry] # Subscribe to reaction events SidekickComp.StartPlayReactionEvent.Subscribe(OnReactionStarted) SidekickComp.StopPlayReactionEvent.Subscribe(OnReactionStopped) OnSidekickMoodChanged(PreviousMood: sidekick_mood, NewMood: sidekick_mood): void = Print("Mood changed from {PreviousMood} to {NewMood}") OnReactionStarted(Reaction: sidekick_reaction): void = Print("Started reaction: {Reaction}") OnReactionStopped(Reaction: sidekick_reaction): void = Print("Stopped reaction: {Reaction}") ``` -------------------------------- ### Inventory Management: Add, Remove, and Query Items Source: https://context7.com/vz-creates/uefn/llms.txt Manages an inventory component by adding, removing, and querying items. It checks if an item can be added, adds it, and subscribes to inventory change events (Add, Remove, Equip, Unequip). It also demonstrates how to retrieve all items, find specific item types, get equipped items, and remove items. Dependencies include UnrealEngine.com/Itemization and Verse.org/Simulation. Outputs are print statements indicating inventory actions and item details. ```verse using { /UnrealEngine.com/Itemization } using { /Verse.org/Simulation } ManageInventory(Inv: inventory_component, ItemEntity: entity): void = # Check if item can be added if (FailureReason := Inv.CanAddItem(ItemEntity, AllowMergeItems := true)): Print("Cannot add item: {FailureReason}") else: # Add item to inventory Inv.AddItem(ItemEntity, AllowMergeItems := true, AllowPartialItemMove := true) # Subscribe to inventory events Inv.AddItemEvent.Subscribe(OnItemAdded) Inv.RemoveItemEvent.Subscribe(OnItemRemoved) Inv.EquipItemEvent.Subscribe(OnItemEquipped) Inv.UnequipItemEvent.Subscribe(OnItemUnequipped) # Get all items in inventory AllItems := Inv.GetItems() for (Item : AllItems): Print("Item in inventory: {Item}") # Find items of specific type SpecificItems := Inv.FindItems(item_component) # Get equipped items EquippedItems := Inv.GetEquippedItems() # Remove item from inventory if (FailureReason := Inv.CanRemoveItem(ItemEntity)): Print("Cannot remove item") else: Inv.RemoveItem[ItemEntity] OnItemAdded(Result: add_item_result): void = Print("Item added to inventory") OnItemRemoved(Result: remove_item_result): void = Print("Item removed from inventory") OnItemEquipped(Result: equip_item_result): void = Print("Item equipped") OnItemUnequipped(Result: unequip_item_result): void = Print("Item unequipped") ``` -------------------------------- ### Define Custom NPC Patrol Behavior in Verse Source: https://context7.com/vz-creates/uefn/llms.txt Provides a Verse code example for creating a custom NPC behavior by inheriting from `npc_behavior`. This behavior allows an NPC to patrol a series of defined points using navigation. Requires '/Fortnite.com/AI' and '/Verse.org/Simulation' modules. The behavior is executed when the NPC begins. ```verse using { /Fortnite.com/AI } using { /Verse.org/Simulation } PatrolBehavior := class(npc_behavior): PatrolPoints: []vector3 = array{} CurrentPointIndex: int = 0 OnBegin(): void = # Called when NPC spawns if (Agent := GetAgent[]): if (Character := Agent.GetFortCharacter[]): if (Nav := Character.GetNavigatable[]): loop: # Navigate to each patrol point CurrentPoint := PatrolPoints[CurrentPointIndex] Target := MakeNavigationTarget(CurrentPoint) Result := Nav.NavigateTo(Target, MovementType := movement_types.Walking) if (Result = navigation_result.Reached): Nav.Wait(Duration := 2.0) set CurrentPointIndex = (CurrentPointIndex + 1) mod PatrolPoints.Length else: break OnEnd(): void = # Called when NPC despawns Print("Patrol behavior ended") ``` -------------------------------- ### Create Colors from HSV and Temperature in Verse Source: https://context7.com/vz-creates/uefn/llms.txt Shows how to generate colors in Verse using the HSV color model and blackbody temperature. Includes functions to convert colors back to HSV or sRGB tuples. Requires the '/Verse.org/Colors' module. Outputs color variables and tuples. ```verse using { /Verse.org/Colors } # Create color from HSV (Hue: 0-360, Saturation: 0-1, Value: 0-1) MyRedHSV := MakeColorFromHSV(0.0, 1.0, 1.0) # Pure red MyYellowHSV := MakeColorFromHSV(60.0, 1.0, 1.0) # Pure yellow MyPastelBlue := MakeColorFromHSV(210.0, 0.3, 0.9) # Light blue # Create color from temperature in Kelvin WarmLight := MakeColorFromTemperature(3000.0) # Warm/orange light Daylight := MakeColorFromTemperature(5500.0) # Neutral daylight CoolLight := MakeColorFromTemperature(8000.0) # Cool/blue light # Convert color back to HSV tuple (Hue, Saturation, Value) := MakeHSVFromColor(MyRedHSV) # Convert color to sRGB tuple (RedComponent, GreenComponent, BlueComponent) := MakeSRGBFromColor(MyPurpleColor) ``` -------------------------------- ### Handling Player Input Actions in Verse Source: https://context7.com/vz-creates/uefn/llms.txt Configures player input actions like Jump, Move, and Interact. It subscribes to various input events (triggered, canceled, detection begin/ongoing/end) and maps them to specific callback functions. Requires external input action assets and player input component. ```verse JumpAction: input_action(tuple()) = external {} MoveAction: input_action(vector2) = external {} InteractAction: input_action(logic) = external {} SetupPlayerInput(Player: player): void = if (PlayerInput := GetPlayerInput[Player]): # Add input mapping InputMap: input_mapping = external {} PlayerInput.AddInputMapping(InputMap) # Get input events for jump action JumpEvents := PlayerInput.GetInputEvents(JumpAction) JumpEvents.ActivationTriggeredEvent.Subscribe(OnJumpTriggered) JumpEvents.ActivationCanceledEvent.Subscribe(OnJumpCanceled) JumpEvents.DetectionBeginEvent.Subscribe(OnJumpDetectionBegin) JumpEvents.DetectionOngoingEvent.Subscribe(OnJumpDetectionOngoing) JumpEvents.DetectionEndEvent.Subscribe(OnJumpDetectionEnd) # Get input events for move action MoveEvents := PlayerInput.GetInputEvents(MoveAction) MoveEvents.ActivationTriggeredEvent.Subscribe(OnMoveTriggered) OnJumpTriggered(Player: player, Value: tuple()): void = Print("Jump triggered by {Player}") OnJumpCanceled(Player: player, Value: tuple(), ElapsedTime: float): void = Print("Jump canceled after {ElapsedTime} seconds") OnJumpDetectionBegin(Player: player, Value: tuple()): void = Print("Jump button pressed") OnJumpDetectionOngoing(Player: player, Value: tuple(), ElapsedTime: float): void = Print("Jump button held for {ElapsedTime} seconds") OnJumpDetectionEnd(Player: player, ElapsedTime: float): void = Print("Jump button released after {ElapsedTime} seconds") OnMoveTriggered(Player: player, MoveVector: vector2): void = Print("Move input: X={MoveVector.X}, Y={MoveVector.Y}") ``` -------------------------------- ### Work with Color Alpha and Blending in Verse Source: https://context7.com/vz-creates/uefn/llms.txt Illustrates creating and blending colors with alpha transparency in Verse using the `color_alpha` type. Demonstrates the `Over` operation for compositing colors. Requires the '/Verse.org/Colors' module. Outputs blended color variables or prints an error message. ```verse using { /Verse.org/Colors } # Create color with alpha (RGBA: 0.0 to 1.0) TransparentRed := MakeColorAlpha(1.0, 0.0, 0.0, 0.5) # 50% transparent red SolidBlue := MakeColorAlpha(0.0, 0.0, 1.0, 1.0) # Fully opaque blue TransparentGreen := MakeColorAlpha(0.0, 1.0, 0.0) # Default alpha = 1.0 # Blend two colors with Over operation (CA1 over CA2) if (BlendedColor := Over(TransparentRed, SolidBlue)): # BlendedColor is now TransparentRed composited over SolidBlue set ResultColor = BlendedColor else: # Both colors had alpha = 0.0, blend failed Print("Blend operation failed") ``` -------------------------------- ### Create Colors from RGB, Hex, and Named Values in Verse Source: https://context7.com/vz-creates/uefn/llms.txt Demonstrates how to create Verse colors using sRGB float components, integer RGB values, hex strings, and predefined named colors. Requires the '/Verse.org/Colors' module and optionally '/Verse.org/Colors/NamedColors'. Outputs color variables. ```verse using { /Verse.org/Colors } # Create color from sRGB float components (0.0 to 1.0) MyRedColor := MakeColorFromSRGB(Red := 1.0, Green := 0.0, Blue := 0.0) MyGreenColor := MakeColorFromSRGB(Red := 0.0, Green := 1.0, Blue := 0.0) # Create color from integer RGB values (0 to 255) MyBlueColor := MakeColorFromSRGBValues(Red := 0, Green := 0, Blue := 255) MyOrangeColor := MakeColorFromSRGBValues(Red := 255, Green := 165, Blue := 0) # Create color from hex string MyPurpleColor := MakeColorFromHex("#9932CC") MyCyanColor := MakeColorFromHex("00FFFF") MyTransparentRed := MakeColorFromHex("#FF0000AA") # Use predefined colors from NamedColors module using { /Verse.org/Colors/NamedColors } MyWhiteColor := NamedColors.White MyBlackColor := NamedColors.Black ``` -------------------------------- ### Merge Items and Handle Categories with Item Component Source: https://context7.com/vz-creates/uefn/llms.txt Provides functions to merge items, check mergeability, and access item categories. It also includes a function to pick up items from the world and place them into an inventory component. ```Verse using { /UnrealEngine.com/Itemization } MergeItems(SourceItem: entity, TargetItem: entity): void = if (SourceComp := SourceItem.GetComponent[item_component]): if (TargetComp := TargetItem.GetComponent[item_component]): # Check if items can be merged if (SourceComp.CanMergeInto[TargetItem]): # Merge all items SourceComp.MergeInto[TargetItem] # Merge specific amount SourceComp.MergeInto[TargetItem, TargetAmount := option{10}] # Check item categories Categories := SourceComp.Categories for (Category : Categories): Print("Item category: {Category}") # Define mergeable item types MergeableTypes := SourceComp.MergeableItemComponentClasses for (MergeableType : MergeableTypes): Print("Can merge with: {MergeableType}") # Pick up item from world PickUpItem(ItemEntity: entity, Inv: inventory_component): void = if (ItemComp := ItemEntity.GetComponent[item_component]): ItemComp.PickUp[Inv] ``` -------------------------------- ### NPC Navigation: Navigate Character to Destination Source: https://context7.com/vz-creates/uefn/llms.txt Controls NPC movement using the navigation system. It allows setting the destination, movement type (e.g., Running), reach radius, and partial path allowance. It also handles different navigation results like 'Reached', 'PartiallyReached', 'Unreachable', and 'Blocked'. Dependencies include Fortnite.com/AI and UnrealEngine.com/Temporary/SpatialMath. Outputs include print statements indicating the navigation status. ```verse using { /Fortnite.com/AI } using { /UnrealEngine.com/Temporary/SpatialMath } NavigateToTarget(Character: fort_character, Destination: vector3): void = if (Nav := Character.GetNavigatable[]): Target := MakeNavigationTarget(Destination) # Navigate with custom parameters Result := Nav.NavigateTo( Target, MovementType := movement_types.Running, ReachRadius := 100.0, AllowPartialPath := true ) if (Result = navigation_result.Reached): Print("Destination reached") else if (Result = navigation_result.PartiallyReached): Print("Partially reached destination") else if (Result = navigation_result.Unreachable): Print("Cannot reach destination") else if (Result = navigation_result.Blocked): Print("Path blocked") # Set movement speed multiplier (0.5 to 2.0) Nav.SetMovementSpeedMultiplier(1.5) # Stop navigation manually Nav.StopNavigation() ``` -------------------------------- ### Create Basic 3D Shapes in Verse Source: https://context7.com/vz-creates/uefn/llms.txt This code snippet demonstrates how to create and add various basic geometric shape components (cube, sphere, cylinder, cone, plane) to entities within the scene graph. It utilizes the UnrealEngine.com/BasicShapes and Verse.org/SceneGraph libraries. The function takes an entity as a root and spawns new entities with attached shape components. ```Verse using { /UnrealEngine.com/BasicShapes } using { /Verse.org/SceneGraph } using { /Verse.org/Simulation } CreateShapes(RootEntity: entity): void = # Create cube component CubeComp := cube{} if (CubeEntity := spawn_entity[RootEntity]): CubeEntity.AddComponent(CubeComp) # Create sphere component SphereComp := sphere{} if (SphereEntity := spawn_entity[RootEntity]): SphereEntity.AddComponent(SphereComp) # Create cylinder component CylinderComp := cylinder{} if (CylinderEntity := spawn_entity[RootEntity]): CylinderEntity.AddComponent(CylinderComp) # Create cone component ConeComp := cone{} if (ConeEntity := spawn_entity[RootEntity]): ConeEntity.AddComponent(ConeComp) # Create plane component PlaneComp := plane{} if (PlaneEntity := spawn_entity[RootEntity]): PlaneEntity.AddComponent(PlaneComp) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.