Sports player movement - momentum and direction changes.

Discussion in 'Game Development (Technical)' started by Alistair Hutton, Nov 8, 2009.

  1. Alistair Hutton

    Alistair Hutton New Member

    Joined:
    Jun 13, 2007
    Messages:
    60
    Likes Received:
    0
    This is one of those, "it must be so obvious I'm missing it" moments.

    I'm sketching out some code for doing a rugby game (Sensible soccer style graphics/ethos). I'm trying to work out how to handle player movement.

    I want the idea of agility, top speed and acceleration being player properties. Top speed and acceleration are (obviously) easy if dealing with a straight line. hat can't work out is how to apply agility to the equality (i.e. turning)

    So a player is heading for the try line and then they are instructed to head towards the touchline. The effect I'm looking for is that the player will 'arc' round as they change heading with more agile players able to turn faster and thus have smaller/shorter arcs.

    I just can't work out how to represent al the related data to get this effect.

    How do I want to represent the players position, current movement and target movement to get this effect. What's the really obvious thing that I'm missing?
     
  2. ChrisP

    Indie Author

    Joined:
    Feb 5, 2007
    Messages:
    971
    Likes Received:
    0
    If you really want arcs, I'd suggest adding a "maximum turning speed" parameter as well - i.e. model players pretty much like wheeled vehicles. However, I imagine the turning speed would be pretty fast, as people don't tend to run in large arcs, and can usually just turn around on the spot. I'm not sure I'd bother; just interpolate from the old velocity to the new velocity and call it a day. With appropriate animations I bet it'd look fine.
     
  3. Screwball

    Original Member

    Joined:
    Aug 2, 2004
    Messages:
    84
    Likes Received:
    0
    Take with a grain of salt but I would do something like the following:

    You would probably want some sort of rotation function that rotates and object at a certain number of degrees per second and then modify that based on speed and agility. So, for instance, let's say your scale for speed and agility is ten, with one being uncoordinated and slow, five being average and ten being extremely fast.

    So probably what you want is a standard degree's per second turn when the person is at average (5). You then increase the angle if the person has high agility or decrease it if they have low agility. You would then increase the angle if they are moving slowly or decrease it if they are moving fast.

    So let's say for every point of agility a person can rotate an extra 5 degree's per second. If a person moving at speed 1 can turn about 90 degree's in a second if they have agility 10, 85 degree's agility 9 etc. Let's also say for every point of speed a person loses five degree's of mobility per second. So the same agility 10 person turns 90 degree's per second at speed 1, 85 at speed 2 etc. You now should essentially have:

    Turning Speed per second = 90 Degree's + ( ( Agility x 5) - 50 ) + ( ( Speed x 5) - 50 )

    Obviously you tweak it depending on how your numbers rank and what you want to play more of a factor in, agility or speed.
     
    #3 Screwball, Nov 9, 2009
    Last edited: Nov 9, 2009
  4. zoombapup

    Moderator Original Member

    Joined:
    Nov 25, 2004
    Messages:
    2,890
    Likes Received:
    0
    One thing you might want to think about is from Craig Reynolds stuff on steering behaviours.

    Imagine you have a circle out in front of the player. You're target point is ALWAYS on this circle. Normally the circle would be fairly small and far out in front of the player. As more opponents are sensed in front of the player you both shorten the distance between the player and the circle (thus making turning more sharp) and increase the size of the circle (making turns more extreme). Then just apply different rotational acceleration and circle radius/distance changes per player property.

    I've seen this make pretty convincing looking avoidance for a similar case.

    Maybe look at "opensteer" for examples of sports game steering behaviours.
     
  5. Alistair Hutton

    Alistair Hutton New Member

    Joined:
    Jun 13, 2007
    Messages:
    60
    Likes Received:
    0
    Told you it was so obvious I'd miss it. That gives pretty much exactly the effect I'm looking for, with more agile players have a shorter interpolation period. The only thing I need to tweak is the effect of going is the effect of head to pos (x,y) and then wanting to head to (-x,-y). What shoud happen is the player slows down then reverses direction. What actually happens is that the player continues on for a few frames in the original direction at full speed before suddently switching direction to head for (-x,-y). This is because I'm interpolating between the destinations rather than the straight velocities.
     
  6. vjvj

    Indie Author

    Joined:
    Sep 25, 2004
    Messages:
    1,732
    Likes Received:
    0
    Assuming my memory is not failing me here, I think sports games like FIFA/Winning Eleven generally have some sort of threshold; if the angular delta is below the threshold you get the above interpolation, while a delta greater than the threshold will have the player do a hard stop + turn in place.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer