Download

How to draw a Path in Realtime?

I want to the player be able to draw a path in real time and then a character will walk that path.
How would I go about doing this?

Here is what I like to do

https://www.youtube.com/watch?v=-TB6Wf7HlJ0

Look into screen to world point. For example, spawn an actor with a spline component and when the mouse is held down, every few milliseconds add a spline point passing in screen to world point. That will create splines along where the mouse traveled. Then you can add a spline mesh component or line particles to display the spline to the player.

Is screen to world point a node? I don’t see it.

Yes, it requires a player controller I believe. Get Player Controller and drag out from it then search for the node.

737f88dc77f41c9b6fe473967bc6757bae0c2cf0.png

So you’d get your player controller, get mouse position from it, then get the mouse position converted to a world position. This is essentially a spot on the camera lens.

The direction is the way your camera is looking, its forward vector. Multiplying the forward vector by a scalar or distance float mean you’re creating an invisible line from the camera straight out for however many units, like 1000 in this example.

Add the scaled direction to the world location. Then cast a line trace from the screen-to-world-point that ends at the screen-to-world-point plus scaled direction. Wherever it hits in the world is where you should be placing spline points. Not every tick, but every few milliseconds using a timer. Line cast every tick if the mouse is held down (or whatever triggers this event) but only add a spline point every few milliseconds.

Thanks a lot! I will give this a try tomorrow.

Let me know how it goes

Ok this is what I got so far. If you see something weird, please let me know but I think I got what I need.

Pawn BP:
e41cac4a84694e88964e0b03d8b2fe14549ce864.png

Actor BP:
ActorBP.png

Is this much different for vertical splines? For example, say you were to rotate a plane 90 degrees.

I think it would work the same. Been awhile but I think I did what you said when I was working on this.

https://youtu.be/ZADGZNs7AkQ