본문으로 건너뛰기

Spawn & Manage Joint Actor Instance with Joint Subsystem

This document will cover the basic principles of managing & creating & finding Joint instances in your world using Joint Subsystem.

This part of the system is not a clever or complex one unlike other core features of Joint so the concept is very straight-forward.

Joint Subsystem

Joint Subsystem is a game instance subsystem that provides features to create a new Joint actor instance, find and manage existing Joint instances in your world.

img.png

노트

Please notice that these functions are declared as static functions, so you can call them without having to get the subsystem instance first.

Creating A New Joint Instances

You can create a new Joint instance actor with CreateJoint. It's just a simple SpawnActor wrapper function that spawns a Joint actor instance in your world, and specifies the Joint Manager to be used for the instance.

img_1.png

This function is not replicated or utilizing RPC, so if you want to create Joint instances on multiplayer games, you have to call this function on the server side only.

important

Creating Joint doesn't automatically start the Joint instance! You have to call StartJoint function on the created Joint instance to start it.

img_7.png

Finding Joint Instances

You can find existing Joint instance actor with FindJoint, GetAllJoints.

img_2.png

FindJoint function requires the Joint instance's Guid to find the instance, and returns the Joint actor instance if found.

You can store the Guid of the Joint instance that you want to store and use it later to find the instance.

img_3.png

GetAllJoints function returns all the existing Joint actor instances in your world as an array.

Global Joint Start & End Delegate

Joint Subsystem also provides delegates for Joint begin & end events, OnJointBeginDelegate, OnJointEndDelegate.

You can access the subsystem on both c++ and bp, and bind events to the delegate to get the Joints that has been played on the session.

img_4.png

Why is my delegate not being called when my Joint starts?

This is one of our most frequently asked questions about Joint Subsystem delegates - and for the most cases the reason is that the delegate binding is happening too late.

This happens especially when you bind the delegate on BeginPlay event of an Actor, and the Joint instance has already started before the Actor's BeginPlay event is called. (maybe from the other Actor's BeginPlay event, or from the level's BeginPlay event)

This issue itself is not avoidable, but we provide a workaround for this issue: you can get the Joint instances that has been played or ended on the current frame with GetJointsGuidPlayingOnThisFrame, GetJointsGuidEndedOnThisFrame.

img_5.png

The subsystem will collect those guids every frame, so you can call these functions on your Actor's BeginPlay event to get the Joint instances that has been started or ended on the same frame as your Actor's BeginPlay event.

So, you can simply call these functions to see any missout, and then bind the delegates after that. For example, the following blueprint shows how to do that:

img_6.png