Spawn decal by dragging mouse

How would i go about creating a decal that has it’s startpoint set where i press the left mouse button and end point where i release it like this?

The arrow is the mouse movement while the left mouse button is held down. And when it’s released i want to spawn a decal(the rectangle). So far i’ve been trying to use a while loop but that won’t work i think i’ll need some kind of gate but i don’t know how it would be implemented.

A decal in the 3d world? Or you just want to draw a 2d rectangle - like a marquee selector?

I got reasonable results by simply scaling it:

Image from Gyazo

Could you show me the entire bp? It does look exactly like what I need except for the fact that i need it to ignore collision since i’m gonna use it as a world space selection tool

Here it is:

edit:

i need it to ignore collision since
i’m gonna use it as a world space
selection tool

You can disable decal projection per static mesh in the hidden part of the rendering panel. Receives Decal is on by default.

I created a custom object type for the floor so I do not click on anything else. Set the object type to whatever type your floor is. You may need to enable on click events in the controller.

I am afraid i can’t get it to work, I have it in my player controller blueprint and apart from that the only differences from your demo and my trying it is that i use the topdown template and a landscape and i set the object types to StaticWorld and I tried DynamicWorld. Other than that i’ve copied everything. The problem i am having is not that it’s not doing anything when i press Left Click

I’m too bad with the engine and game development in general to understand everything you’re saying but i can place buildings and other stuff on the landscape but for some reason i can’t get the decal to work. Did you create a component for you decal inside the player controller or did you only create a variable? Trying to find anything that’s different from mine

Got it to work now tho somewhat scuffed, guess it’s just the numbers that i need to adjust a tiny bit, will put as resolved soon! Thanks as every other time you’ve been the one to help me out :stuck_out_tongue:

I had it easy here as I was clicking on one surface, I can imagine it being more difficult on a rolling terrain. Perhaps you’d need to take the normal into account or an average normal of the area to make it feel right. Never done anything like that, never worked with terrain in UE4.

Anyway, glad to hear you got it working!

Good luck with the rest.

A loop makes no sense to me. You only need to update it once per tick, so i would just put it in the Tick event

What i’m saying is i need the corner
where the mouse button was pressed to
be fixed(right now the scaling makes
it jump a little between two points)

If you look at the animation I linked, you’ll notice that it is, indeed, quite fixed - completely immobile, tbh. There’s was no jiggling on my end and it does expands in one direction only. Could you demonstrate the issue?

and i need the scaling to only allow
sizes where X and Y divided by 100 is
equal to a whole number.

For this you could use SnapToGrid (float) node for both start and end points.

Been trying to use this system and make a it snap every 100 units but it seems that it expands in both directions on both axis’s. I would need a way to make this system only expands in one direction both in X and Y. Would that be something you could show me how to do?

What i’m saying is i need the corner where the mouse button was pressed to be fixed(right now the scaling makes it jump a little between two points) and i need the scaling to only allow sizes where X and Y divided by 100 is equal to a whole number.

I tried the snap to grid but it’s the same problem, I don’t have any software to record and make a GIF but sometimes an axis expands at both ends and if I jiggle the mouse a bit I just move the decal and it doesn’t change size(while using floor on the scaling).

So the problem kinda is that sometimes it only moves and then it snaps and corrects it’s size despite the fact that I am using snap to grid.

I managed to fix it by snapping the end point(sloppy on my end to not even think about that) thanks as always for clear and fast answers!

One last thing, can I make it snap the startpoint as well? I tried snapping directly from the break hit result but I can still start at places I wish I couldn’t. I can make my selections overlap by half a snap which is how I realized the problem.

The system will be used to spawn a stockpile so having them be in the same “grid” as the other buildings would be quite nice ^^

That’s what I’m doing, any other clue what could make it work?

Screenshot:

Admittedly, I did not test it thoroughly. It was a quick 15 min thing. I might find sometime early next week to replicate this and figure out what issues remain and have a look at the snapping.

Keep hammering at it until it works! :smiley:

That’s what I’d try first, apply the snap before Set Start / End. Should work but can’t tell for sure.