Announcement

Collapse
No announcement yet.

How to draw a Path in Realtime?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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

    #2
    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.
    Procedural, modular, on-the-fly animation - iTween For UE4
    - Actors - Components - UMG - Ease In - Ease Out - Path-constrained Animation - $0

    Runtime Datatable
    -All the fun of DataTables dynamically loaded from text or Google Sheets while your game is running!

    Comment


      #3
      Is screen to world point a node? I don't see it.

      Comment


        #4
        Yes, it requires a player controller I believe. Get Player Controller and drag out from it then search for the node.
        Procedural, modular, on-the-fly animation - iTween For UE4
        - Actors - Components - UMG - Ease In - Ease Out - Path-constrained Animation - $0

        Runtime Datatable
        -All the fun of DataTables dynamically loaded from text or Google Sheets while your game is running!

        Comment


          #5
          Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	89.3 KB
ID:	1070848

          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.
          Attached Files
          Procedural, modular, on-the-fly animation - iTween For UE4
          - Actors - Components - UMG - Ease In - Ease Out - Path-constrained Animation - $0

          Runtime Datatable
          -All the fun of DataTables dynamically loaded from text or Google Sheets while your game is running!

          Comment


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

            Comment


              #7
              Let me know how it goes
              Procedural, modular, on-the-fly animation - iTween For UE4
              - Actors - Components - UMG - Ease In - Ease Out - Path-constrained Animation - $0

              Runtime Datatable
              -All the fun of DataTables dynamically loaded from text or Google Sheets while your game is running!

              Comment


                #8
                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:
                Click image for larger version

Name:	Pawn.PNG
Views:	1
Size:	307.9 KB
ID:	1071590

                Actor BP:
                Click image for larger version

Name:	ActorBP.png
Views:	1
Size:	664.4 KB
ID:	1071589

                Comment


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

                  Comment


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

                    Comment


                      #11
                      https://youtu.be/ZADGZNs7AkQ

                      Comment

                      Working...
                      X