No announcement yet.

How to move a UStaticMeshComponent with code?

  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Answered here:

    Leave a comment:

  • started a topic How to move a UStaticMeshComponent with code?

    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.

    Click image for larger version

Name:	CodeProblemMovingSkeletalMeshComponent.png
Views:	1
Size:	26.9 KB
ID:	1137904

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

    Much thanks,