Solved Mariokart-like game - Places. [HELP!]

Discussion in 'Plugin Development' started by HRSN0410, May 23, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    HRSN0410

    I am trying to make a game (similar to Mineplex's minekart) and I need to implement a system where it tells you what place you are in. The game has three circular laps. Can anybody help me?

    Thanks :)
     
  2. Offline

    VortexGmer

    1) Mineplex Minekart? What the heck is that?!?
    2) Is this a request?
     
  3. Offline

    Corndogoz

    ok, once you get thinking, this can be kinda easy, here are the steps:
    1. Save to the config the coords the finish line is at
    2. make a hashmap<Player, Integer> that has all the peoples names in game, and their number of laps(you tell the laps by whenever they go over the finish line)
    3. then your first if statement is to check if people r in the same lap or a higher lap then another
    im not gonna tell you the rest, cause people always say: you tell people exactly how, dont do that! so yeah, that should get you started
     
  4. Offline

    HRSN0410

    No, this isn't a request.

    You can disregard what I said about Mineplex's Minekart.

    I've already figured that out, the part I need is the part that you didn't say. If it was a linear track I could compare X or Z values, but since the track is circular, I am not sure what the best way to compare them would be.
     
  5. Offline

    blablubbabc

    Some quick idea how it could maybe be done, without going to much into details:
    *divide your track into straight segments for each of which you know the start location and a length (basically a vector for each segment)
    * figure out in which segment the player's car currently is (see below)
    * project the car's position onto the segment vector by using the dot product: with this you should get a distance relative to the start of the segment: with this distance and lengths of all previous segments you can calculate the progress on the track for each player and then sort those, to find out the player's positions

    Regarding 'figuring out the segment a player currently is':
    Maybe one can figure out in which segment a player is by keeping track in which segment the player was last (starting at the first one), projecting the car's position onto that segment, and if the projected distance to the start of the segment is larger then the length of that segment, continue to the next segment and do the same there.

    If the track is circular and you detect that the player is past the last segment, you can increase a lap counter for the player.

    You can also detect player's going backwards on the track: if the projected postion-vector is facing the opposite direction than the segment vector, then you continue to the previous segment instead.

    Alternatively: you can also see all segments as actual areas and do intersection tests with those to find the one the player is currently in. This might maybe be even better to prevent certain kinds of problems, like in case the players can move a large distance (for example around a complete curve) in the time between when you would update the player's current segment / check if they moved to the next segment(s).
     
    Last edited: May 23, 2015
  6. Offline

    Corndogoz

    this is acctually a very good way todo it, however, if the server lags, it might think your in a different segment then ur in
     
  7. Offline

    HRSN0410

    Okay, thanks for your help! I got something working :)
     
Thread Status:
Not open for further replies.

Share This Page