how to modify a blueprint for placing a 3D grid of objects in order to use different objects with respect to depth and distance from the view center?

I am currently using the construction script in the picture to place copies of the same mesh in a 3D grid.

I need to modify this to use different versions of the object according to the assigned position in the 3D grid with respect to the camera and center of the application window(essentially the center of the camera view).

For the sake of keeping things simple let’s say I have a threshold D1 for camera distance and threshold D2 for distance to the window center. So

  • if (dist. to cam) <= D1 and (dist. to center) <= D2 : place ObjectVersion A
  • if (dist. to cam) > D1 and (dist. to center) <= D2 : place ObjectVersion B
  • if (dist. to cam) <= D1 and (dist. to center) > D2 : place ObjectVersion C
  • if (dist. to cam) > D1 and (dist. to center) > D2 : place ObjectVersion D

Distances need to be calculated according to X,Y,Z of the assigned position in the 3D grid for each location index. For example, in a 3x3x3 grid, there are 27 such locations.

Can you help me realize this in the blueprint? Currently, I can’t even get the camera location in the construction script.

Auxiliary question: should I still use a construction script for that? I mean: Is what I need realizable as a construction script? If not, what should I switch to and how?

Please note that this is not a homework but actually for my scientific research. So all constructive feedback is much appreciated to advance our research.

There is no camera during construction.

You can use a point held in a variable, during runtime, you can set that variable to the camera position.

You also need as many ISMs as you have distinct meshes. Once for each mesh type.

If you want to do it at runtime, with a large number and / or the focal point moving around, that’s more tricky. You’d have to keep track of which instance was which. It might be easier to just use a grid of blueprints.

1 Like

This is great! I will try and let you know.

What do you mean by a grid of blueprints?

1 Like

You can spawn a grid of actors, like this, but they are all blueprints.

Each BP can calculate its own distance from the focal point, and change mesh accordingly.

1 Like