Download

How can I disable Z in a vector??

I’m still very new to the BP system, so, please pardon my noobness.

I’m doing a tutorial on making procedural content. The idea is pretty simple, just spawn a random mesh in various positions when you drag it into a level…

What my question is; how do I just make it randomly place objects on the X and Y axis while leaving Z at 0?? (I want the bushes to snap to the ground).

Here’s a pic of what I’m doing…

Looks like I figured it out… Added in a convert to 2dVector.

First: Ground may be at a place different than 0. Using raycasts is generally better.
Second: It’s easier to multiply (not cross!) by the vector (1, 1, 0) which avoids converting back and forth.

You can also drag off vectors and type “break vector” or drag off floats and do “make vector”. This way you can do a break transform on the random unit vector and connect the X and Y axis but not the Z axis to a Make Vector.

Adding to the list of way this can be done :smiley:

2017-02-13_14-24-44.png

Thanks for the help, much appreciated.

So, I added in the break vector like you said @Pinworm. Works great.
@jwatte I’m not sure what Raycast to use? (I’m still new to all this BP stuff)

Here’s my updated BP:

The line trace you’d be looking for is LineTraceByChannel

To explain what that method is and why to use it, say you have a terrain where the elevation increases and decreases. Suddenly, your bush blueprint won’t work - since the Z-axis changes. So what you’d do is instead of spawning bushes at random X by Y locations, you would - in your construction script so you can see it in-editor - instead use those locations to start a line trace down.

You’d make the line trace start where the bushes are spawning now, and raise your actor into the sky. Make the end of the line trace the start location - 0,0,10000. Then, off the hit location, that is where you spawn your bush.

To explain what this will do, in-editor as you drag your bush BP around, it will do line traces down from random locations. This will create a line to see if it hits anything. When it hits the ground, it will spawn the bush there. This way, you can just drag this around and not have to worry about height at all!

@Pinworm

Okay, I’m not getting it to work. This is what I have so far; what am I doing wrong here?? :confused:

You need to actually pay attention to the OutHit result, which will tell you where the ground actually is.
You need to make the start vector take the X and Y of your “initial location” – as it is, you’re just tracing from the origin.
You need to make the end vector be negative Z, so it’s below the ground.