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"

How to get static mesh position in Blueprint

I have a blueprint that contains several static mesh components. I need to find the (world) position of the static meshes. The individual meshes are modelled such that they fit together perfectly without manually moving them in UE4, therefore I can't just get the local offset (it is always 0).

  • I have tried to add Sockets to the original meshes, but they are not available in the blueprint (querying all the sockets returns none at all and in details panel, only the parent socket shows up).

  • I have tried to get the vertex data. I have allowed CPU access on the static meshes, but when trying to access them via "Get Section from Static Mesh", I don't get any sections at all, and thus also no vertex data.

  • I have tried to calculate the bounds of the mesh, but that always returns 0 for both min and max.

Product Version: UE 4.21
Tags:
more ▼

asked Nov 21 '18 at 09:01 AM in Blueprint Scripting

avatar image

TimLobner
5 1 1 5

avatar image TimLobner Nov 21 '18 at 09:26 AM

I have placed scene components into the blueprint now to help myself, but i'd still like to know an answer to the question, because I need to do this for several BPs that may contain arbitrary amounts of static mesh components.

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

alt text

alt text

more ▼

answered Nov 21 '18 at 10:13 AM

avatar image

tranduil
83 7 17 18

avatar image TimLobner Nov 21 '18 at 10:20 AM

As I said in my question, the Meshes are modelled such that the fit together withouth any translation in UE4. Therefore the relative location is 0 for all the static meshes

avatar image tranduil Nov 21 '18 at 10:25 AM

did you try to use the first image?

avatar image TimLobner Nov 21 '18 at 10:27 AM

Yes, but that returns the position of the scene component under which my static meshes are set into the blueprint

(comments are locked)
10|2000 characters needed characters left

Have you tried simply using GetWorldLocation on the static mesh component itself?

Get world position

capture.png (329.7 kB)
more ▼

answered Nov 21 '18 at 10:38 AM

avatar image

Weibye
250 1 7 5

avatar image TimLobner Nov 21 '18 at 10:56 AM

Yes, but that returns the position of the scene component under which my static meshes are set into the blueprint, too, because of the way the individual meshes are not model around their own center

avatar image Weibye Nov 21 '18 at 03:19 PM

Unreal stores all transforms in the origin of the mesh, so if you have modeled your static meshes to "be somewhere else" than the origin, then "getting the world position of the mesh" isn't a meaningful sentence as it will only return the location of the origin, which isn't useful to you.

I don't think there are any simple way to do what you want to achieve without changing the actual meshes so that each of them has an origin in a meaningful location, instead of having every origin at a common zero.

avatar image TimLobner Nov 21 '18 at 03:25 PM

"getting the world position of the mesh" isn't a meaningful sentence as it will only return the location of the origin, which isn't useful to you.

I realize that, which is why I tried vertex positions and Sockets. I have seen others work with vertex positions especially, but I don't see why it works for some static meshes but not in my case. So far as I could find, you have to allow the CPU access to the static meshes, and then you can query them via getting a segment of the mesh. However as I mentioned, my static meshes don't have any segments (or at least querying the number of segments returns 0), and I don't know how to fix that.

avatar image Tuerer Nov 21 '18 at 04:04 PM

Idk, as a temporary workaround you can put an additional invisible mesh into your mesh as a child, and get the world location of that. Not the best way though, but might work.

avatar image TimLobner Nov 22 '18 at 07:03 AM

That is kind of what I did, as for now I added scene components into the blueprint where the meshes are.

(comments are locked)
10|2000 characters needed characters left
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