How to move a UStaticMeshComponent with code?

Hello, for the past few days I am struggling with this coding problem.

I have an actor class named Item from which I made a blueprint. The blueprint consists of a USphereComponent which is the RootComponent and a UStaticMeshComponent which is parented to the USphereComponent.

I store these items in a TArray to prototype an inventory idea. If I move my cursor over the item, it saves a reference to the item in my inventory TArray. Now what I am trying to do is when pressing a key, the first item in that TArray appears where my mouse cursor is.

It does move the RootComponent, but the UStaticMeshComponent does not want to move. The following image shows the 2 marked lines where I am trying to move the actor in code. The first one works which moves the RootComponent. The second won’t work.

I hope that someone would know why the mesh won’t move.

Much thanks,

MrB

Answered here: