x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Moving 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.

alt text

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

Much thanks,

MrB

Product Version: Not Selected
Tags:
more ▼

asked Aug 28 '14 at 12:34 AM in C++ Programming

avatar image

MrB
3 1 2 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Set Mobility Movable

you have to specifically tell Static Mesh Components that they can move!

This is set to static by default for lighting optimization reasons

 //Mobility
 StaticMeshComponent->SetMobility(EComponentMobility::Movable);


your case

 //Mobility
 ItemMesh->SetMobility(EComponentMobility::Movable);


Rama

more ▼

answered Aug 28 '14 at 06:59 PM

avatar image

Rama
10.6k 446 343 1085

avatar image MrB Aug 28 '14 at 07:22 PM

Thanks for the anwser Rama.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question