Trying to spawn meshes from editor utility BP

I’ve been trying to spawn some meshes via editor utility bp and it’s getting there, but I can’t wrap my mind around some of these issues.

  1. I am trying to spawn the actors aligned by an axis (X in this case) and they seem to be using the world rotation instead of the actor one. I’ve offset this by rotating the forward vector by the actor rotation and it’s working but not 100%. Why is the axis still rotated slightly as seen in this image?

  1. I’m also working on a functionality to destroy overlapping actors. I’m not looking for full precision, but the overlap test doesn’t go through at any point. I used an int to test if the for’s go through and they do and both matrices are populated with my actors. Why does the overlap test always return false.

I assume this is working like a construction script? In which case, Ease doesn’t really mean anything. Also, once you have your forward vector, you have the direction, that’s it.

books

Ah, ok. The ease is to randomize the placement…

2 Likes

I can randomize the same code with

image

and put some lean in with

image

But rather than removing overlaps afterwards, it’s better to go for none in the first place. This code does make overlaps, but given a bit more time, I think I can fix it…

3 Likes

Ok, I got as far as ‘chance of book spawning’, and ‘chance of leaning’ without overlaps

Don’t know if this is of any use… :smiley:

3 Likes

Hi, thanks for the ideas. I thought about doing the overlap test beforehand but i was to deep into this one and postponed thinking about it :slightly_smiling_face: i’ll try integrating this and I’ll get back to you as soon as I test it out. :hugs: also the leaning idea for the books is neat, i’ll probably work it in with a toggle somewhere.

1 Like

I tinkered a bit with it today. Got the axis right with the steps you described above and now it’s lining up properly. I’ve been trying to hook the book size up to the mesh bounds so that the placement remains accurate with multiple meshes.

I also managed to take the size of the box I’m using as a spawner in order to keep the meshes inside only by comparing the Cummulative distance with the scaled box extent X of the box.

Can’t get the math right yet, but I think I’m getting closer (getting random gaps in between books without any randomization implemented).

I’m also going to be working on the math to move the spawn origin at the edge of the box so it fills the whole space from left to right.

Still having problems with the overlap part though, as mesh sizes vary.

Glad to hear it’s working better.

I think using mesh bounds might be problematic, in the long run. It can bear no relation to the collision box, if that box is rotated.

bounds

2 Likes

Took a while to get through this one :sweat_smile: .

So I managed to get the size spacing to work with bounding boxes. Got the box before rotating the mesh in-scene so the size would always be accurate. I took your idea to use Cummulative distance instead of overlap tests and used a vector to store the values on X, Y and Z. Only managed to get the functionality on the right vector (X in-world) with the other axes being a bit buggy atm. For what I need right now it works, so I’ll finish that part sometime in the future. Added an Int to select the axis I want.

I also got the line trace on Z to work and move my actors down to the point of collision by measuring the distance between the edge of the bounding box (unrotated size) to the location of the test hit. (had to tinker a lot with the math that got me there :mask: )

I originally wanted to spawn them from the edge of the box, but I changed that so that the actors are moved after spawn to the center of the box on X axis by measuring the array bounds and halving it.

As you can see, when not rotating the box around Y axis, the books spawn without overlap and with random spaces inbetween. This should also work with other meshes too (although the closer to a square the better).

I’ll probably fix the rest of it sometime else and post it here whenever. The suggestion to use cummulative distances was great for what I needed and is easy to expand on, so thank you for the help! :star_struck:

Hey! - it’s coming on nicely :slight_smile: