So, I’ve decided to become the ue4 guru, but I’ve stuck at the beginning
Keep in mind following
class UCustomMovement : public UActorComponent
UPROPERTY( Instanced, BlueprintReadWrite, Category = Impl)
In a character editor I’m creating this custom movement and movement component. Here’s the issue: I want to pass a reference of this movement component to my custom movement, but I can’t find a way to do this.
I’ve been developing using Unity for some time, hence the behaviour I want to get is a SerializedField property.
Patiently waiting for a master to help soon-to-be-master
I think that what vivalavladislav was trying to know, based on the mention of Unity’s SerializedField, is if it’s possible to add a reference, in the Details panel, to a certain component that belongs to a world actor.
I was able to do it by declaring a reference to the actor and the type of component to get.
It works! However, I’m still looking for better alternatives and perhaps a way to get a specific component reference if an actor has multiple components of the same type (like colliders). I wish to avoid getting all such components (using GetComponentsByClass) and then using their string names to differentiate them, though that might not be possible…
Ok, but basicly you are getting the Component of an actor with the mentioned function. I have no idea if this can be done in another way. I’m getting my component refs like this and it works well But for now i didn’t need to get a component that exists more than once on an actor.
Don’t know if you’ve found a better way, but I do it through setting the reference manually using BP nodes.
For example, in my BeginPlay event, I manually get a reference to both components, and then use the “Set [Name of Variable]” node and pass the reference. I’d love for metadata to be able to describe where to find the component and allow direct setting in the details window, but that’s a good workaround.
Edit: Oh yeah, you might also want to mark the property “VisibleAnywhere” so that you can’t set it to something invalid from the Details panel.
I’m also interested in this. I didn’t want to go through the event graph because I want those references be set in the property window. So far all I can do is set the component’s name and wire the references in code.
Just to add a little explanation to this for beginners:
You create both variables (actor and component references). The component reference is not an particular instance, but after executing this you will have to find if that actor has that type of component or not.
If you want to do it just with “actor” and not asking for a component type, I suggest you call the same to get “comp” but instead of TypeOfComponent, you call YourComponentClass::StaticClass(). You can’t use “YourComponentClass” name directly on GetComponentByClass.
If you add the class specifier EditInlineNew to one component you can create a reference to it from another component in the property window. However, it will create a new component, instead of referencing a pre-existing one.
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent), EditInlineNew)
class UFirstComponent : public UActorComponent
class USecondComponent : public UActorComponent