Im making a tower defense game and im trying to get the turret to spawn on top of the block this is what im using now but its not actually doing anything !
Any advice?
Im making a tower defense game and im trying to get the turret to spawn on top of the block this is what im using now but its not actually doing anything !
Why not do it with a line trace?
I am really new to UE4 could you explain what a line trace is?
edit: also how to use it would be amazing!
Okay
There is something called a line trace. It’s where the computer draws a line from whatever point you want outwards into 3D space. What you’d use here is a Line Trace from underneath the mouse and then see whatever it returned was a place where you could place a tower or not. Like, say, some special blueprint you put on the ground where only towers can stand.
Then you do the rest from there, because now you have the location to place the tower and the object you need to manipulate like making it disappear or what have you
You should do a line trace from where you want to spawn it (The mouse location?) + a few hundred Z units, to wherever you want to spawn it - a few hundred Z units. Then on the line trace, you have the ‘Out Hit’ , from that you can do ‘Break hit Result’, and that will return a struct that has the properties from the line trace. The ‘Hit Location’ vector will be the location at the surface. Personally I’d use ‘Line Trace by Channel’ as it returns the true surface because it’s not dependent on objects, but either should work for you. You should also set the ‘Draw Debug Type’ on your line trace to ‘For Duration’, this will help you see the line trace.
This is what I have now, but the string is not getting printed still? Is there something im doing wrong?
The event must not be firing, do you have collision setup for the sprite?
What would I attach the location node to?
I think that the event is not actually going through because even when I attach a print to the OnClick nothing happens? What would cause the click event to not work?
Still need help anyone know why the event wouldnt work?