Assign UStaticMesh to Root Component

Hey eveyone,

i’ve just started learning c++ coding in UE4 though i am not completely new to c++ in general,
To start up i followed along the official tutorial series with the Battery Collector Example.
The woman in the tutorial used UE v4.9.
In the Constructor of the Pickup Class she does the following:
RootComponent = PickupMesh;

I am getting the error, that it is not possible to assign an entity of UStaticMesh* to USceneComponent*.
What do I have to do ?
And furthermore would you guys suggest me to keep following this maybe “outdated” tutorial series ?
Thanks for any help.

Hi it sounds like you grabbed the wrong Variable here. You want to use tha Variable that is a UStaticMeshComponent* (Thats the Component that is responsible to Render Meshes, it uses a UStaticMesh* via SetMesh(TheMesh)) and not UStaticMesh* (Thats your Model)

Its also Possible that they made a mistake in the Series that gets corrected in the next Episode.

But in general the Logic stays the same there maybe small changes here and there and you can find those changes very easy via the search or official Docs. Another thing to note is that the Tutorial is 7 Versions behind and every Version Comes with Pages long Changes that can in fact change a Function name or add/remove Parameters or even more dramatic Changes sometimes.

You can always look into the sourcecode or the Api to See what Functionality exists and what Parameters they take with a small description on the side. But usually the Function name already is self explaining. Here two examples.

Dont get overwhelmed by the amount of Functionality thats in there most of the time you use only a small Portion of them =) If you cant find your Function there its probably because its inherited from its Parent so you can look there.

(example hierarchy) Screenshot - a8f36ee376ef685074232073a7c33719 - Gyazo

And dont worry you will learn how to navigate and orient around the more you Code. If you can afford or want to do a 30day trial I can recommand you https://www.wholetomato.com/ that plugin is a powerhorse for Navigation and Codehints.

Good Luck mate =)

Hey thanks very much for that detailed answer ! :slight_smile:
It definitely helped me getting further on this.