Some programming feedback

So i have been using Unity for quite some time so that post is going to be kind of “What i wish UE4 would have that unity have”

A GetComponent<T>() method for actor so that we can get a component of specific type. I know there is such function but its not exposed in blueprints because of generics i assume. Are you going to change that somehow?

Some love for Interfaces. They are really crippled or the documentation is crippled or im blind and i can’t find how to do things.
Been trying to make an interface that:

  • Is implementable in blueprints
  • Is overridible in code
  • Is overridble in blueprints

what i came up with



//UsableInterface.h
UINTERFACE(meta = (CannotImplementInterfaceInBlueprint))
class INTERFACE_API UUsableInterface : public UInterface
{
	GENERATED_UINTERFACE_BODY()
};
class INTERFACE_API IUsableInterface
{
	GENERATED_IINTERFACE_BODY()

public:
	UFUNCTION(BlueprintCallable, Category = "Interact")
		virtual void Interact(AActor* ActorInteracting);

};

And in implementing class
//InventoryOnTheGround.h


class INTERFACE_API AInventoryOnTheGround : public AActor, public IUsableInterface
{
	GENERATED_BODY()
	
public:
void Interact(AActor* ActorInteracting) override;
UFUNCTION(BlueprintNativeEvent, Category = Interact)
		void OnInteract(AActor* ActorInteracting);
};
//InventoryOnTheGround.cpp
void AInventoryOnTheGround::Interact(AActor* ActorInteracting)
{
	OnInteract(ActorInteracting);
}


But obviously i cannot implement it in blueprints. Is there a posibility of doing BlueprintNativeEvent in Interface?

Another thing that i have issues with is Data Objects
In Unity i would make a pure c# class that i would hold a reference in a monobehaviour
That would allow me to easily modify the data from the inspector, is there a way to have properties of an object inside an actor to display its properties in the editor? Making a class and instantiating it everytime i want to make a new type of weapon seems redundant. Feature like Property Drawer from unity in some way would also be really nice.

Heard that there will be features of it in 4.8, maybe 4.9. But that is a bit far on the roadmap.

Please don’t take my word for it.

Hi Illusive_S,

It has been a few years since I last used Unity (I think 3.5 was the last version I used), so I apologize if I don’t have a good grasp of some of your feedback.

With your comment regarding GetComponent<T>(), I am guessing that you are wanting to be able to get a component of a specific type in a Blueprint that you have made from an Actor class? There is a Get Components By Class node in Blueprints that will give you an array of any components in an Actor that are of a specified class. Is this not quite what you are looking for?

Components.PNG

With regards to Data Objects, are you looking for a way to be able to change the properties of a code class without having to create a Blueprint of that class or put the class directly into the level? I looked up the Property Drawer in Unity, but I think that is slightly different to what you described (an additional feature request, perhaps?) I will poke into both the Data Objects and Property Drawer a bit more tomorrow to see if there may already be something comparable in UE4.

Ah it used to return ActorComponents that i needed to cast and from what i can see in 4.7.3 the comment is still saying that its required
But its not, glad to have that cleared out

Something that i would love to see is
DataObject.png
And maybe property drawer to display a few variables is kind of overboard just displaying the properties would be awesome

I’ll admit that I have not used this particular node very often (maybe two or three times), so I don’t recall off the top of my head how it may have worked in previous versions of the Engine. The current version, however, allows you to specify the class of components that you are looking for, then outputs an array of that type of component. I did not try anything more complicated than setting up the screenshot that I provided, so if you run into any issues with it not working the way you expect, please let us know.

Unfortunately I ended up being fairly busy this week, and didn’t have a to look over Unity’s Data Object and Property Drawer information. I’ll try to familiarize myself with those this weekend and see what I can come up with.