Summary of ideas and execution


This started as trying to get an implementation of a C++ interface working with blueprints. 

Steps to Implement the Interact Interface

  1. Define the Interface: The interface class was correctly set up with a virtual Interact function.
  2. Implement the Interface in an Actor Class: An example AMoundOfDirt class was provided, showing how to implement the Interact function.
  3. Implement Interaction in the Player Character: The player character class was modified to detect interactable objects and call the Interact function.

Roadblocks and Resolutions

  1. Incorrect Syntax for Interface Execution: The user encountered issues with the syntax INNF_WorldInteractInterface::Execute_Interact(HitActor). It was clarified that the correct approach involves using UFUNCTION macros with appropriate specifiers like BlueprintNativeEvent and BlueprintCallable.
  2. Mapping Static Meshes to Body Parts: The user wanted to create a map between static meshes and body parts. An enum for body parts and a struct to hold the mapping were suggested. The actor class was then implemented to use this struct and enum.
  3. Attaching Objects to Player: The user needed to attach a body part to a socket on the player's skeletal mesh. The AttachToComponent method was used to attach the spawned actor to the specified socket.
  4. Playing Animation Montages: The user wanted to play an animation montage when an item is picked up. A function PlayMontage was created in the player character class to handle this. The function was exposed to Blueprints for easier management of timers and looping animations.
  5. Refactoring to Avoid Spawning New Actors: The user refactored the code to attach the existing actor to a socket instead of spawning a new one. This involved modifying the Interact_Implementation function to handle the attachment directly.
  6. Creating a Zombie from Body Parts: The user aimed to create a mechanism where different body parts are attached to a coffin, and once all parts are attached, a zombie AI character is spawned. A coffin actor class was created to track attached body parts and spawn the zombie when all parts are present.

Final Implementation

  • Coffin Actor Class: The ABP_MainCoffin class was created to hold body parts and check for completion.
  • Player Interaction: The player character class was modified to handle picking up and placing body parts, interacting with the coffin to attach body parts.
  • Detaching Body Parts: A function was added to the coffin class to detach body parts when interacted with.

Conclusion

The conversation covered various aspects of implementing an interaction system in Unreal Engine using C++ and Blueprints. The user faced several roadblocks, including syntax issues, mapping static meshes, attaching objects, and playing animations. Each issue was resolved with detailed explanations and code examples, leading to a robust implementation of the desired features.

Files

NecroNeedleFrankenstienBuildCut.zip 975 MB
May 26, 2024

Leave a comment

Log in with itch.io to leave a comment.