Hi. i m trying for a few days now with no success and i would like to know : how can i spawn a decal when i press and drag a button from UI to the rest of the screen. Basically i want to be able to drag a button anywhere on the screen when pressed, and spawning a ghost decal following my touch location at screen and interpretate it to world location while always staying on ground (ignoring z input) and then spawn the decal at the location of the release.
below you will see an example of the basic idea. I did this example in the character but you could easily adapt it to and bp.
to begin we need some type of input (a button press or key press) or custom event, here i used left mouse button. on pressed be create the ghost decal then open the gate. the gate will allow tick to enter and pass through once opened which will then run the set world location node. here you could use a timer instead of tick to save some performance or for aesthetic purposes. now the location for the set location node we need to be determined by the mouse location so we get the player controller and get hit result under cursor. this will basically do a line trace from the camera where the cursor is into the world and get a result which we can break and get a location from. you could also just get the mouse position and do the math yourself if you were so inclined. the last thing we need to do is tell the decal where we want it to be placed which we do by just closing the gate, ending the set world location.
now there is also a few more steps for your specific case, namely changing the decal to the final one. there’s two options here, first you could just change the decal material, second you destroy the first decal and spawn in the final one. both options can be done on input released you would just need to use a sequence or put the script before the gate.
hmmm well the return value should tell you if there was a hit on the vis channel so you could put in branch off that to interupt the tick and run a destroy actor. that would basically do the same thing as canceling out the creation and movement of the decal.
You Sir, are a life saver. Just got it working exactly like i wanted to. Any chance you know which hit result cancels it when i move the decal out of screen location/visibility?
Ok, i fixed that too. Thx again! Now the only thing missing is how to set touch input boundaries in a circle around my character
not sure on input boundaries but the below will limit placement, though its probably not a optimal solution performance wise.
Yeah, this works just fine! The only problem is that it stops drawing the decal at the point of the limit instead of locking it within this circle
I finally found out what was happening. It was the z axis position. When i broke down the vector and made a new one it all worked as planned. Thx again