Results 1 to 15 of 15

Hybrid View

  1. #1
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    156

    Default Mouse Cursor + Commands through mouse

    I followed the full tutorial here: http://udn.epicgames.com/Three/Devel...ace.html#Using the _PlayerController and HUD to provide the mouse interaction

    Even after integrating it into my files, I attempted to just use THEIR source code in the January UDK and the custom Kismet won't register, it DOES take in the 2d mouse coordinates which I logged, but it does not register as it explains it should on the website... Am I supposed to switch to AS3? Or what do I do? Is this completely outdated?

  2. #2
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    156

    Default

    Does no one have any ideas? =(

  3. #3
    MSgt. Shooter Person
    Join Date
    Nov 2011
    Posts
    108

    Default

    read through the gems thread that id stickied at the top of programming, and UnrealScript there is a small discussion of it, and if that does not correct the problem then post there, and the person that wrote it will be able to help you.

  4. #4
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    156

    Default

    What I've been able to get is this post from Solid Snake:

    __________________________________________________ ______
    This is because MyHUD is handled by the Engine and is assigned an instanced of the player's HUD. However, to be honest the mouse code is actually not relevant anymore because as of UDK October you can now just retrieve the mouse coordinates using this code snippet in your own custom HUD class. I do plan to update the MouseInterfaceGem with this new change.

    YourHUD.uc
    Code:
    event PostRender()
    {
    local LocalPlayer LocalPlayer;
    local Vector2D MousePosition;

    Super.PostRender();

    // Abort if no player owner
    if (PlayerOwner == None)
    {
    return;
    }

    LocalPlayer = LocalPlayer(PlayerOwner.Player);
    if (LocalPlayer == None || LocalPlayer.ViewportClient == None)
    {
    return;
    }

    MousePosition = LocalPlayer.ViewportClient.GetMousePosition();

    Super.PostRender();
    }

    _______________________________________________

    So basically... What I'm understanding is... this is the fix, let me see how I can fit that into his gem!

  5. #5
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    156

    Default

    I've tried integrating this code in, but it still does not register on screen like it should. I'm not fully understanding what to do with this I guess.



    Edit: I think my best bet is taking the RTS tool kit, and working DOWNWARDS to create a functioning mouse interface and interaction within the game I'm working on!
    Last edited by vvolynine; 02-26-2012 at 07:49 PM.

  6. #6
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    What you don't understand from that tutorial?

  7. #7
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    156

    Default

    Well, I implement the tutorial correctly no errors...
    I tried it first doing it through my game files and integrating it there, no dice, while I'm in game, it registers the scaleform location of the mouse just fine, but WILL NOT INTERACT with the world or kismet.
    I then tried to just use the EXACT SOURCE CODE provided by the UDK GEM, and still, no dice... exact same thing. Scaleform registers, throws 2d coordinates, does NOT interact with the world.

  8. #8
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Quote Originally Posted by vvolynine View Post
    Well, I implement the tutorial correctly no errors...
    That's don't mean, that there is no errors...
    First download source from that tutorial, then make it work. Once it work and you understand how it work, try adp to your project.

  9. #9
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    156

    Default

    I did. It doesn't work. The exact source code only half-functions. The creator himself said that past October it breaks or something like that. That is why I'm looking for a fix or some help.

  10. #10
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Then why you tried adp broken code?
    Quote Originally Posted by vvolynine View Post
    The creator himself said that past October it breaks or something like that.
    That's mean, that code is no more compatible...
    Last edited by VendorX; 02-26-2012 at 08:13 PM.

  11. #11
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    156

    Default

    It's not broken. He said it's not relevant or something like that because of some new function... Which means this code should still work just as well. I'm looking for help and suggestions to people who USE this specific gem and how they got it to work... Not to be asked redundant questions.

  12. #12
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    If i find some free time, i will look closer at that code - you meantime continue asking, maybe someone already find way out.

  13. #13
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    156

    Default

    No problem, I'll go through and double check everything, I probably missed one stupid step. I have it 95% working. I can probably figure this out within the next hour. Also a shout out to Solid Snake for making such sexy gems... damn!

  14. #14
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,514

    Default

    No problems, let's try to get things going for you.

    If you can retrieve the 2D mouse coordinates via Scaleform, mouse delta appending or reading from the system coordinates then you're half way there.

    The next thing you want to do is to calculate the 3D plane coordinates. Imagine your screen is the plane, and somewhere on this plane is the coordinates of where the 2D mouse coordinates is. This is what the Canvas.DeProject() function does for you. DeProject() returns two vectors. One vector represents the point on the plane (blue dot), and the other vector represents the direction which you can use to perform a trace (blue line).



    Code:
    // MousePosition is the 2D coordinates representing the mouse in screen space.
    function MouseInteract(Vector2D MousePosition)
    {
      local Vector MouseWorldOrigin, MouseWorldDirection, HitLocation, HitNormal;
      local Actor HitActor;
    
      // Ensure that we have a valid canvas and player owner
      if (Canvas == None)
      {
        return Vect(0, 0, 0);
      }
    
      // Deproject the mouse position and store it
      Canvas.DeProject(MousePosition, MouseWorldOrigin, MouseWorldDirection);
    
      // Perform a trace to get the actor the mouse is hovering over
      HitActor = Trace(HitLocation, HitNormal, MouseWorldOrigin + MouseWorldDirection * 65536.f, MouseWorldOrigin , true,,, TRACEFLAG_Bullet);
    
      // Do what you want with Actor, HitLocation and HitNormal
    }
    The code snippet above, shows how you use the deprojected 2D coordinates to then perform a trace within the world. The Actor that the trace returns is the actor that is "underneath" the mouse cursor.

    If the HitActor is WorldInfo, then the trace has hit BSP. If the HitActor is None, then the trace did not hit anything. Otherwise the trace will an actor in the world.

    The HitLocation is a point in the world where the trace hit. This is usually garbage or Vect(0, 0, 0) if the trace did not hit anything.

    The HitNormal is a direction vector that is equivalent of the surface normal of the surface that the trace hit. This is garbage if the trace did not hit anything.


    So with that out of the way, the next question is how you would go about linking this with the mouse or the button press. So one thing you need to be very careful is the order you do things. While you can use DeProject from within LocalPlayer, it is slower than the one in Canvas. So for performance reasons, what I usually do is when a player presses a button to execute an exec function; I would then cache it as a pending action. Then when the Canvas is ready, I then check if there is a pending action, and from there I gather what actor the mouse is over and then perform actions.

  15. #15
    MSgt. Shooter Person
    Join Date
    Sep 2011
    Posts
    156

    Default

    Thanks a bunch for this detailed explanation. It works just fine now. Now to add functionality to it such as player movement and so on, this will take some time Thanks again


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.