Set rotation on instanced static meshes

Hello,

I’m trying to instance a number of static meshes around the default scene root.
I would like all the meshes to always face the root.
the amount of meshes, and the distance from the root is dynamic (as the distance increases, more meshes spawn so that it’s always a complete surface (though not always 360°) )

Does anyone know how I can make this work ?

Thank you!

hi @CupKake

i assume you only spawn them on a plane.
so first thing the distance,
Make a Vector variable with 0,0,100 for example.“Direction”

Make a loop for the number of meshes you want to spawn, lets say 15 ok?
i use add static mesh component, be aware that he use the relative transform, make a new transform and feed in the “Direction” from before for the location
The rotation is tricky .
Now use “rotate the vector” on your “Direction”, and use again the 360/Nmesh as angle. Set this new rotated vector to “Direction”.
Repeat the loop until all meshes are placed.

For the rotation set the Z rotation you have to play with it a little , i am not sure
basically you want to set it to something like Index of loop* 360/Nmesh.
If you add 15 mesh , 360/15 = 24 degrees,
the firist second and third mesh should be rotated of 24 - 48 - 72 - 96
based on the relative transform and starting direction you have to add another “something” 0-90-180-270

Thanks for the response!

Unfortunately this is way over my head.

Could you explain a bit more what an Nmesh is?

I was really hoping for something like a “look at constraint” …

thank you

Quote me when you reply so i can get a notification :slight_smile:

Nmesh is nothing, just the Number of meshes you want to add.

If you want for the rotation you can use this https://docs.unrealengine.com/en-US/…ion/index.html

You are okay with making a vector to spawn meshes?
Using the loop to rotate the vector ?
Once you spawn the mesh, pin out his world location, and pin in the start of look at rotation,
then get the world location of the thing you want the meshes point at, maybe the center of the actor?
so fet the reference to “self” pin out the world location, and pin in the target of look at rotation,
use the return value to set the rotation of the static mesh.

is simplest doing it than reading it

I see, I think I understand what you’ve explained above…except this one part

in the screengrab I posted about, i’m setting the transform before spawning the mesh, after the "add instance " node, I can’t drag off a “get location” node …what’s the best way to get the location of the spawned instances?

I’m getting this error on the SetLocationAndRotation Node…

Instanced static mesh are light but different too, i am not an expert about instanced stuff so i suggest you to :

add-static-mesh instead of isntanced, this will give you a return pin witht the reference to the mesh and you will be able to pin out the location
OR
Since you spawned the Instanced-Mesh, the location is the same you have in the transform before the spawn,
grab the location from there , check if is relative or not !

I’m not 100 percent sure how to add a static mesh, I don’t see it as a option when I drag off …

the Add Static Mesh Component node is expecting an Actor target…

or perhaps in the screenshots above you can see what I’m doing incorrectly?

thank you again!

And I should quote you, so hopefully you see this!

Thank you!

Are you working in an actor? or in the level blueprint?

I’m working in an actor.

In your actor right click and write Add static mesh component , (is in add component- common group, like in your image)

that node will create an empty static mesh component, then you need to “set static mesh component” to say wich model you want to show,
also use set material and set location and rotation…
Like in the Blueprint.com stuff… be sure that every node will have a target , you need to plug in the return value “the reference” of the new static mesh.

Awesome, I’ve made it spawn the static meshes.

I’ve would have thought the nodes here would have them face the Default Root, but …they all seem to face the same direction…but at least I can SET them!

any idea how I can get them to face the default root of the blue print?

the “rotation base” variable is set to zero, maybe that is the problem?

thanks again!

no the problem is what you feed in the "“find look at rotatio” The forward vector.
"find look at rotation " ask you for 2 coordinates, (Start) where is the object and (Target) where you want that he look toward.


See this image for a correct one.

this will rotate the meshes so they will face with the x+ direction the default_scene_root.

THIS WORKS!

Thank you for helping me get this working!

Using the static mesh component seems much more straight-forward than instancing.
Also, understanding what Find Look at Rotation node was doing, was critical.

Thank you again!