Announcement

Collapse
No announcement yet.

Shoot Towards Mouse Location not working

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

    Shoot Towards Mouse Location not working

    Okay so I am trying to make it so when I shoot it goes towards the mouse location I have done it before and it worked but right now it is just shooting to this one default point. The first photo is of the code that checks where the mouse is I believe this is where my problem is. The second photo is of the code to make the thing shoot and this works just fine from what I can tell. and I had a picture of the bullet moving to the one default point as I am calling it but its to big for this so yeah if anyone has any idea what I am doing wrong please tell me PS: I did try to use get mouse location and this made it so I could aim but only on the X or Y axis

    #2
    If you need anymore info just ask me (:

    Comment


      #3
      1. Set a Line Trace from the camera forward. Get a Hit Location.
      2. Find Look At Rotation from the Muzzle EndPoint to the Trace Hit Location.
      3. Spawn the projectile using the vector you get from #2
      Don't do this in tick. No need.

      Comment


        #4
        Mr. Wood
        Originally posted by Mr. Wood View Post
        [LIST=1][*]Set a Line Trace from the camera forward. Get a Hit Location.
        It’s a 2D game so I don’t think a line trace from the camera is gonna do anything right? It would just go to the middle of the screen

        Comment


          #5
          And also the first part of the code is the only thing in Event Tick to find out where the mouse is at all times the second screenshot is not in event tick if that was cause it any confusion

          Comment


            #6
            And for the 2nd thing I need to make it so that the muzzle follows the mouse I don’t have a problem with it shooting. And that also goes for the 3rd thing I am trying to make it shoot towards the mouse and I have done it before where the muzzle follows the mouse but for some reason this time it’s not working

            Comment


              #7
              Well I could just add a camera to the muzzle/play but I would still need to fix it not changing depending on where the mouse is

              Comment


                #8
                Maybe try something like:
                Get actor location (start projectile location) -> connect with Find Look at rotation Start
                From controller Get Hit Result Under Cursor By Channel -> connect with Target
                - Add Make Transform Node
                - Break Hit Results from Get Hit Results...
                Connect output from Find Look At Rotation with Make Transform Node (rotation) and also connect Location
                Also you can always draw debug line (or line trace) for testing.
                And debug in tick: Draw Line trace from your character to Get Hit Results Under Cursor to see what's going on.

                Comment


                  #9
                  Thank you Mr. Wood That worked like a charm

                  Comment

                  Working...
                  X