Announcement

Collapse
No announcement yet.

Single Line Trace somtimes goes through landscape

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

    #31
    You are doing a trace every tick, is it important that every single tick hits the landscape? I mean what if you just try to ignore those blank results or if you get a blank result try to do a second trace with a slightly offset X,Y position as target?
    Free Inventory System (BP AND C++ Version): Clicky Clicky
    Player Structure System (Houses!) (BP): Pew Pew Marketplace Version: Yoink!
    Howto: Create Dragable UMG Windows: Zoom Zoom

    Comment


      #32
      Originally posted by ruohki View Post
      You are doing a trace every tick, is it important that every single tick hits the landscape?
      Yes, it is. Think about sending units around in an RTS Game. The player clicks, and nothing happens. He clicks again at the same location, and again nothing happens. The Unit would never move, unless the player is moving the mouse to another location. This is extremely frustrating for the player, isn't it?

      Originally posted by ruohki View Post
      what if you just try to ignore those blank results or if you get a blank result try to do a second trace with a slightly offset X,Y position as target?
      A slightly offset may produce large differences in where the trace hit's the landscape. Think about a mountain in the foreground and some other stuff in the background. The player might click the edge of a mountain, but if the trace would be 1 pixel to the right, the trace may hit the background.
      Easy to use UMG Mini Map on the UE4 Marketplace.
      Forum thread: https://forums.unrealengine.com/show...-Plug-and-Play

      Comment


        #33
        Okay would you test a trace on click? I think the every tick stuff is the problem( iam doong this in a project myself, dont have that issue) like in the rts example
        Free Inventory System (BP AND C++ Version): Clicky Clicky
        Player Structure System (Houses!) (BP): Pew Pew Marketplace Version: Yoink!
        Howto: Create Dragable UMG Windows: Zoom Zoom

        Comment


          #34
          Hi John,

          I no longer have this issue, here's what i'm doing:

          in my HUD BP i update the vectors DeprojectWorldLocation and DeprojectWorldDirection each tick by using Deproject from GetMousePosition.
          Then each tick in my playercontroller BP i trace from the DeprojectWorldLocation in DeprojectWorldDirection and every trace (after the first) returns the correct value.

          I hope this helps

          Comment


            #35
            Originally posted by ruohki View Post
            Okay would you test a trace on click? I think the every tick stuff is the problem( iam doong this in a project myself, dont have that issue) like in the rts example
            I need to do it every tick.

            Originally posted by Thommie View Post
            in my HUD BP i update the vectors DeprojectWorldLocation and DeprojectWorldDirection each tick by using Deproject from GetMousePosition.
            Is there some special thing I have to mind while using deproject? It just returns (0,0,0) for me...

            Click image for larger version

Name:	625a2e8f3c.png
Views:	1
Size:	80.5 KB
ID:	1061493

            "Get mouse position" works fine.
            Easy to use UMG Mini Map on the UE4 Marketplace.
            Forum thread: https://forums.unrealengine.com/show...-Plug-and-Play

            Comment


              #36
              Deproject is a pretty poorly implemented function. Use the cousin-function "convert screen location to world space".

              Also, FYI, consider swapping the line trace for a sphere/capsule trace with a narrow diameter. If the problem is that a single point doesn't register the trace, then the sweeping of geometry across that point will automatically catch another nearby point when a slightly wider part of the sphere collides instead.

              Comment


                #37
                Originally posted by RhythmScript View Post
                Deproject is a pretty poorly implemented function. Use the cousin-function "convert screen location to world space".
                Thanks, that works, but it doesn't solve my problem.

                Thommie, it doesn't make any difference whether I do it like you said or like I did it before. I still have the same problem.
                Does it really work for you with a landscape? With normal static meshes I also don't have any problem.


                Originally posted by RhythmScript View Post
                Also, FYI, consider swapping the line trace for a sphere/capsule trace with a narrow diameter. If the problem is that a single point doesn't register the trace, then the sweeping of geometry across that point will automatically catch another nearby point when a slightly wider part of the sphere collides instead.
                Thanks, that's a great idea and it works perfectly.

                Click image for larger version

Name:	4ba4a62224.jpg
Views:	1
Size:	402.5 KB
ID:	1061498

                Although, I guess the performance of a sphere or capsule trace will be worse than a single line trace, right? I'm always a a bit cautious with stuff that's executed every tick. So I think it would be really great if Epic would fix this bug.
                Last edited by John Alcatraz; 11-28-2014, 11:44 AM.
                Easy to use UMG Mini Map on the UE4 Marketplace.
                Forum thread: https://forums.unrealengine.com/show...-Plug-and-Play

                Comment


                  #38
                  Ah i see i made a mistake, i'm updating it from DrawHUD in my HUD BP, not Tick. I believe deproject doesn't work outside DrawHUD.

                  Also how are you getting that Get Mouse Position node? Mine needs a Playercontroller to work.

                  Comment


                    #39
                    I was going to suggest the trace by sphere thing too.

                    I wouldn't worry about performance on that just yet, either. That kind of thing is basic for the engine (it's doing millions of traces a second on the render as it is). Make sure your trace isn't going pointlessly far, to be on the safe side though

                    Comment

                    Working...
                    X