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"

How to change the pivot point of static mesh using c++?

Hi there, so basically question is in the title. Can anybody tell me how to do that using c++ as I created static mesh using c++ and pivot point is on the bottom of the object and I want it be in the middle. Thank you

Product Version: UE 4.14
more ▼

asked Apr 20 '17 at 02:03 PM in C++ Programming

avatar image

1 1 3 4

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

1 answer: sort voted first

The problem is the mesh that you are using, since they made it with the pivot on the bottom, so it's fairly simple, just get the static mesh component on that actor and move it by half it's height.

I'm not near my computer but you can do something like this (If you are inside the actor we are talking about):

FVector bounds = StaticMeshComponent->GetBounds(); //Move the static mesh on the Z direction only StaticMeshComponent->SetComponentLocation(0.f, 0.f, -bounds.Z * 0.5f);

As I said I'm not near my PC so I cannot test this, but GetBounds() should give you the width, height and depth of the mesh, just adjust the location of it and you will have the pivot in the center.

more ▼

answered Apr 21 '17 at 09:59 AM

avatar image

311 13 12 21

avatar image xvivax Apr 21 '17 at 11:56 AM

I get your idea and it seems to be good, but there is the problem. Static component doesn't seems to have GetBounds() function, only GetLocalBounds() which take two parameters (FVector min and Fvector max) and I dont know what should I put for those min and max?

avatar image voidnullptr Apr 25 '17 at 12:04 AM

I came across this similar question in which they are using GetActorBounds (Link below), In any case I was checking the GetLocalBounds and it takes two "out" parameters, whenever you see a function asking you for a parameter as a reference in which you know you should get something in return that means that those parameters that you will pass into the function will be modified inside of it, it's a very common practice in Unreal because you can call a function to return more than just one value out of it, in this case just create two FVectors and init them to cero, pass them into the function and after calling it check out their values and you will see they got updated. https://answers.unrealengine.com/questions/41596/how-to-get-the-size-of-a-static-mesh.html

(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