Download

getting the world locations on line traces

I have my player drop line traces behind him, I would like to log the location of each line trace that player drops, I have started with a simple line trace that gets the player location and fired that location with a AnimNotofy, for now I was looking at a debug line that would link up at each point, could someone point in the right location on how to achieve this, thanks

what do you mean by link up? like connected? if yes you have to save the old vector and then set it as the end point of the next trace. then you overwrite it again and the current vector becomes the old vector.

Yes, I have try if to find out how to “save” the location of each vector that the player has drop behind him, but I can’t seem to find any docs on it, the mulit line trace doesn’t seem to do it, and cratering a array doesn’t seem do do it, but I’m not shore if I was setting it up correctly
The line was just to see if it was working,

So you just want to get a history of where your player was? Why do you need a line-trace for that?
A simple “Get Actor Location” should be enough to get the World Location.

If you want to save it, add it to an Array of Vectors. Everything else is up to you, since I have no idea what you are trying to achieve.

a vector array works fine for what you want to do. you take the location and make “add” to add it into the array. if you want to print it out you can in the array into a “for each loop”.

the points / the line trace locations are for the interaction of material and other such things, mainly I am looking at crating a spline that the player crates as he walk behind him, again I was look at using this for martial interaction, and other such things, tracking system of Such, the line traces seem to be a essay way of getting a location of where the player has been, and transferring the location From BP to BP, from what research I have done, making my BP’s as flexible as possible makes thing easier down the track, and having the player drop a location just seems to make sense to me as I can see a physically location and track what’s going on when I am playing around.

I have tried the for each loop and making arrays and the Doc cover making them but all the incoming data from the Array is crated are with know variables that the person crates, this is the player crating the vectors in game play, I have tried a few thing like crated a vector array variable and I have 5 slots in that variable, and I make the array and connect it into the line trace vector. i assumed that it would feed the vectors in order from 0-5 so the fist 5 locations would be logged in game play, but that doesn’t seem to be the case, then i “get” the location and use the index and draw debug point to see if that worked but it only ever logs the fist location, all 5 at the one point. i would show you a picture but there not much to show,

it funny because it very essay to find info about Splines and using blueprints to talk to martials it believe I can work that out some what and I have crated thing with this and they work fine, but this is something that just stumps me from the start because of the lack of info.

also thanks for all your time

Sorry I’m confused, I can only every get one “hit location” I can not get the value of each Hit location in any order, has anyone got any examples or where I can find one
thanks

Normally, you create an “Array” of “Vector”. The, when you do the “Line Trace”, you get a “HitResult” from the Trace Node.
You can call “Break HitResult” on it and receive the “Location” and “Impact Location”. Take your “Array of Vectors” and call “ADD” on it.
The “ADD” nodes has an Input for a Vector. Feed it with either “Location” or “Impact Location” of the broken HitResult node.

And that’s it. Every time the Trace happens (and hits) a new Vector will be added to the Array. Of course, the Array only exists runtime, so
if you close the Game, it’s empty again (which is ok, if you only need it this very moment when the Player plays).

You can Limit the Amount of Vectors added by adding a small logic of starting back at index 0 (Arrays count from 0 to Length-1!).

You can pre-size your Array to, for example, 5. You can do this either by editing the Variable directly, or by calling something like “Resize” or so
(can’t remember the exact name) on the Array in your Code.

Then, instead of “ADD” you call “SET” on the Array, which lets you set a specific Index of the Array.

Now you only need a variable that counts from 0 to Length-1 and starts back at 0 if you reach Length.

So you have an INTEGER Variable (create one) and you set the “Location” from the HitResult to with “SET” to Index “IntegerVariable”. Should be 0 at the beginning.
Then you call “Increment” on the IntegerVariable. Then you check if the IntegerVariable is GREATER OR EQUAL (>=) the Length of your Array (5 at this example).
If TRUE (use a branch), set the IntegerVariable back to 0. Otherwise, continue without doing stuff.

To do the Traces, you can use a TIMER. Go to the PlayerCharacter Blueprint and set a Timer on “BeginPlay”. Timers need a Time in Seconds, a bool for if they should loop
and either a FunctionName (So the plain name of the Function that they should call) or an Event, which you can connect via the Red Square at the corner of each Event.

So you would create a Function called “TraceLocation”, do you “Tracing and saving to Array” in this, use “SetTimerbyFunctionName” in the BeginPlay Event.
Set the Time to, for example, 1 second. Set it to loop and that’s it.

Now it fills the Array with a Location each second.

Is that what you need? xD

yes thanks
it was so simple what I was doing wrong, I was using “make array” node and plugging it into my “set array”, there for the Add was doing nothing, and I also now get how to uses the Array nodes, it just makes sense now, i have my line traces in order from witch they are placed in the world,
so if I don’t cap the amount of vectors that get fed into the array it will just keep adding onto it. I was going do this by capping the amount the line traces there fore the flow on would be this anyway, Yes?,
I was also going to look at the Interger variable and see how I can use this, thanks for the info, I will try it out,

thanks to all for your time
a92e650ba9b60191bed1a2772efbce131dfae227.jpeg