Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Make the pawn look at the cursor (sidescroll)

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

  • Make the pawn look at the cursor (sidescroll)

    Hello,

    I am making a 2D sidescroller game (to learn the basics of UnrealScript) and the camera is setup and the pawn moves like I want.
    But I want it to aim at the cursor, my cursor is defined by 3d vector and already displayed on the screen.
    So now I need to find the delta of the pich and yaw but I don't now how to achieve that because I don't know what function I can use to direct the aim.
    What can i do ?

    Best regards,

    rXp>!<

  • #2
    I think I've done something similar once.
    Take a look at what I did in this post.

    There's also a Youtube-clip showing my results - see if it's what you want.

    Comment


    • #3
      Originally posted by Ompakim View Post
      I think I've done something similar once.
      Take a look at what I did in this post.

      There's also a Youtube-clip showing my results - see if it's what you want.
      Seeing the video, yes that is what I'm looking for Thank you a lot
      And I see that our code are think the same way so the changes are extremely little !
      Thank you a lot

      Comment


      • #4
        The code seems correct but the mouse coordinate seems wrong.
        The issue is that that the mouse should be in the center (x and y axis) of the screen for the pawn to turn BUT the cursor think he is at the center way before the actual center.
        Screenshot :
        And the only change made on the actual position is this one :
        event PlayerInput(float DeltaTime)
        {

        // Add the aMouseX to the mouse position and clamp it within the viewport width
        mousePosition.X = Clamp(mousePosition.X + aMouseX, 0, 1920);
        // Add the aMouseY to the mouse position and clamp it within the viewport height
        mousePosition.Y = Clamp(mousePosition.Y - aMouseY, 0, 1080);
        super.PlayerInput(DeltaTime);
        }
        Do you have an idea ?

        [EDIT] I found the issue, the cursor had a wrong position but the position calculated was good.
        But I see that the cursor is not always where the player shoot :s

        Comment


        • #5
          Originally posted by rXp View Post
          But I see that the cursor is not always where the player shoot :s[/B]
          Hm, that's not good

          Is there a big difference between the cursor and the actual aiming?
          Have you noticed any specific incorrect behaviour? For example; 'only when aiming to the left'.
          If it's just a few degrees, it could be that you just have to adjust the aim by the crosshair's textureheight and width.

          Comment


          • #6
            The first was about that (drawtile). But now the more i look down the more it is incorrect (the crosshair gets too low).
            I calcule the angle with an atan2 of the direction vector (the one that is created by (crosshair2DPos-player2DPos) and add or not pi/2 for the right side , what is wrong ?

            rXp>!<

            Sent from my Galaxy SII using tapatalk.

            [EDIT] Here is some screenshots of the issue :
            OK

            A bit off

            Total off

            Comment


            • #7
              Thanks for pointing this out
              It took a while for me to find the problem, but I managed to fix it eventually.

              I don't know whether you still have this problem or not, but if you do; you can check out my new code in the same old thread: http://forums.epicgames.com/threads/...1#post30115814

              To summarize:
              The problem was I was using the player's 2D-projected position to calculate the aim, while I should have been using the weapon-socket.
              If you fix that, the offset should disappear.

              Comment

              Working...
              X