How can i draw lines with time

Hi
I tryed to make a Line in the widget without animation.
I did it and it worked except that the line is not drawing it self on time like it takes 2 sec to draw.
And is it possible to make the line like only horizontally and vertically like (-|) not (/)?

This is What i used to do.

Do this:

  • in widget graph us EVENT Tick
  • make 2 arrays: source_array (one you have now) and draw_array
  • in event tick “get current game time in seconds” remember those seconds in variable
  • when “current game seconds” is greater than " > " remembered game seconds + some delta time, update remembered game seconds then:
  • do stuff to draw lines: copy ONE point to draw array, increase some index
  • draw that points fro draw array

Thats what i have now

Maybe you can send me a picture how you would solve it.

I got a bit simpler idea to do it:

This uses Finterpto to interpolate on event tick from 0 to last index in points array, make sure you set DrawArrayIndex back to zero when you want draw again (or you can change Target to 0 instead of last index.

Then you have 3 operations on arrays:

  • clear draw array, probably unnecessary here, but added just for clarity of code.
  • then copy/set draw array to what whole Points array contains
  • last is resizing it (which will cut exceeding points)

Result should be points from 0 to INT(Draw Array Index), and those you draw in that widget part from your first post.

Also you may want to optimize that event tick code:

  • remember last index integer (Truncate result) value in separate variable.
  • do not call whole part with arrays operations until that integer index changed (so you update array only when array needs to be updated, and not on every tick

ps.
play with interpto speed and density of points to make if slower/faster.

and there is idea for future:
instead of using fixed points from array, use those points as target where vector interpto is aiming. So draw all points until most recent one, then use vector interpto to approximate end of line smoothly, then update array and make interpto to new end of the line point.

pps (And important):
My code will start working from begin play or construct event.
So you should add boolean or some variable and brach node where you feed target index to interpto.
When you are not ready for drawing points make target “0”, and when you want it to draw points set it to what it is now in code

Could you tell me just for an example the numbers you type in the varriable and do i need the on paint function ?

this is how i did it:

Set speed either to small value or bigger than 1, i just do not remember if its speed or delay in interpto :slight_smile:

then get last index from that draw array and print it out, so you can see if this updates

then use draw array in your first part of code (from first picture in this topic).

It is always 0

Do you have points in your points array?

yes 2 so index 0 and 1

Add more than 2 this code is for multiple points.

Isnt changing :c.
Can you maybe sent a small video where you show me what it looks like not that you mean something diffrent.

I improved that code and tested it. I also added generating of debug circle points, to see if it really works.

If you have your points to draw skip Code in event construct (it is just for testing).

Event tick is almost same, i added checking if index changed, also drawing requires +1 to index value

Important:

  • points array should store all points
  • draw array is what points are drawn (they are copied from points array on index change)
  • circle needs radius and circle steps to be something else than zero.

For horizontal or vertical lines:
[10 ; 10] , [50 ; 10] - this will make horizontal line.
[10 ; 10] , [10 ; 50] - this will make vertical line.

If you do not want drawing all lines in steps, just skip all my code and feed proper points in array.

Also what you want do exactly, what is that line for? I have strange feeling you want do something like health bar.