1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

tracking player location

Discussion in 'Programming' started by mrbungle, Feb 23, 2005.

  1. mrbungle

    mrbungle New Member

    Joined:
    Oct 18, 2004
    Messages:
    17
    Likes Received:
    0
    I saw this thread in the other UT forums:

    http://forums.beyondunreal.com/showthread.php?t=122078&highlight=track+user%2Fplayer+location

    and this is basically what I need to do. However I notice that it extends xpawn and the Runtime does not have an xpawn class. Is there a way to track player location every second and save this information to a log file using the Runtime? Can a mutator work?

    I posted something earlier about an overhead map, but plans have changed. Now we want to track the location of the player, get the raw data, and visualize their movement in an external program (OpenGL or something). I don't need to do any visualizations in Unreal now which frees us up a lot I think.

    This seems like a fairly simple thing to do, but I can't seem to find the Runtime code that tracks player location.

    Thank you!
     
  2. CodeSlut

    CodeSlut New Member

    Joined:
    Feb 22, 2005
    Messages:
    10
    Likes Received:
    0
    I see what you are doing here, but it sounds kind of tricky. One problem I forsee is how you plan to visualize the level in this external program. It sounds like you'll just have a dot hovering in space, but I don't know what this is for so maybe that's all you need.

    In any case, there are a number of ways you can do what you want. You could make your own new gametype like in the thread you linked, or you could use a mutator. You don't need to subclass xPawn; whatever subclass of Pawn the UE2R uses (I believe they use RTPawn but I haven't delved) will do.

    However, I wouldn't necessarily use the method described in the thread you reference if you're using the data to update position in another 3D environment. Communicating through a log file would be a bit clunky. I would look into native code; in other words, calling your C++/OpenGL code from within Unreal, and possibly visa versa. I don't know a lot about this so you'll have to find out from someone/where else. I guess it all depends what you're using this for, and how accurate you need your info to be.
     
  3. mrbungle

    mrbungle New Member

    Joined:
    Oct 18, 2004
    Messages:
    17
    Likes Received:
    0
    Thanks for the info. We are using this information as a visualization of a person's navigaton data. It doesn't need to be done in real time, that is why I was thinking that a log file would be adequate. I was also thinking that a mutator would be sufficient for this. I looked at RTPawn, but it didnt seem to have any sort of player location info, so I am still searching for that.
     
  4. Angel_Mapper

    Angel_Mapper Goooooooats

    Joined:
    Jun 17, 2001
    Messages:
    3,532
    Likes Received:
    3
    log(Location) will give you the location of the pawn, which is the player's location. You can do a log(Name@Location) if you're tracking more than one to keep them separate. A quick subclass to make a custom GameInfo, then set your custom PlayerController and AIController there, then set your custom Pawn class in the controllers and log the location there.
     
  5. mrbungle

    mrbungle New Member

    Joined:
    Oct 18, 2004
    Messages:
    17
    Likes Received:
    0
    Thanks for the info. I was wondering if these things can all be done from a mutator as well, or will the custom Pawn and PlayerControllers be necessary no matter what.
     
  6. mrbungle

    mrbungle New Member

    Joined:
    Oct 18, 2004
    Messages:
    17
    Likes Received:
    0
    So this problem was solved, but in a hacky sort of way. In the RTPawn class I added this:

    Code:
    event PreBeginPlay()
    {
         SetTimer(0.5,true);
    }
    
    function Timer()
    {
        local Controller C;
    
        local string x, y, z, r;
        local string location;
        local FileLog locationLog;
    
        location="locationLog";
    
        locationLog = Spawn(class'FileLog');
        locationLog.OpenLog(location);
    
        for (C = Level.ControllerList; C != None; C = C.NextController)
        {
            if(C.Pawn != None)
            {
                x = "x: "$C.Pawn.Location.X;
                y = "y: "$C.Pawn.Location.Y;
                z = "z: "$C.Pawn.Location.Z;
                r = "r: "$C.Pawn.GetViewRotation();
    
                locationLog.Logf(x);
                locationLog.Logf(y);
                locationLog.Logf(z);
                locationLog.Logf(r);
    
                locationLog.Logf("");
                locationLog.CloseLog();
            }
        }
    }
    This is tracking the player location perfectly and we are very happy with it. However, I would like to implement this in a proper manner (via custom Pawn, PLayerController, and GameInfo classes). I attempted this by basically copying the existing RTPawn, RTPlayerController, and RTGameInfo into a new directory named MyRuntime and renaming the appropriate classes by replaceing the RT with My (yes this is really sloppy, but it is only a test).

    I opened up my test level and changed the LevelInfo's gametype to MyRuntime.MyGameInfo. This loaded perfectly well and the game runs fine. However, the code that was logging player location previously seems to not be called at all, as the log no longer is generated.

    Do I need to explicitly define the Pawn that is being used somewhere in the INI file? Am I forgetting to do something simple to get this to work? Thanks.
     
  7. JohnK

    JohnK New Member

    Joined:
    Oct 29, 2004
    Messages:
    28
    Likes Received:
    0
    The default player type needs to be changed in User.ini

    JK
     

Share This Page