An online resource dedicated to evangelizing XNA to the Greater Boston area. Primary focus is on the XNA Framework and XNA Game Studio.

Realistic follow the leader in the RPG starter kit

Latest post 07-26-2008 8:00 AM by blackpanther. 4 replies.
  • 06-15-2008 3:02 PM

    Realistic follow the leader in the RPG starter kit

    Since the last meeting I've been fooling around with the RPG starter kit and one of the things I was able to do was have the game display all of the members of your party while you are walking around rather than just the main character.  That part wasn't that hard, but I've been strugling with making the party move realistically on the screen.  By that I mean that as soon as the switch direction the whole party is abruptly lined up behind the main character.  So just to help in the visualization of this, if you look at the screenshot below you see the whole party facing to the right

    Right Facing

    As soon as I press to the left, I wind up with this

    Left facing

    What I would like to have happen is for the lead character to change direction and for the following characters to then wait until he has passed their position before they turn and start to follow.  Kind of like this

    Desired movement

    I've gone through about a dozen different attempts at getting this to work, but none of them seem to work.  Has anyone else tried this or have any suggestions on how it should be done?  If people would like to see the code I've used to this point, just let me know and I will upload it to the codeplex site.

    Hosting a codeplex project for the Boston XNA group at http://www.codeplex.com/BostonXNA/.

  • 06-16-2008 7:17 AM In reply to

    Re: Realistic follow the leader in the RPG starter kit

    First, very cool idea.

    Please upload it to the codeplex site, I'd be interested in taking a look at it.

    I think that if you use a 'hit' test to see if the direction vector of the follower does not intersect the position of the player then that follower needs to turn in the direction of the player. Basically, testing to see if the follower is facing the player. Don't move the follower unless it is one unit away from the character it's following.

     

    Michael

  • 06-17-2008 1:22 PM In reply to

    Re: Realistic follow the leader in the RPG starter kit

    Code has been uploaded to codeplax and can be downloaded from the source code tab at http://www.codeplex.com/BostonXNA/SourceControl/ListDownloadableCommits.aspx.  One of the more major changes I did was to refactor the Session.DrawNonCombat method so that it looks like this

    DrawParty(spriteBatch, elapsedSeconds);

    DrawPlayerNPCs(spriteBatch, elapsedSeconds);

    DrawQuestNPCs(spriteBatch, elapsedSeconds);

    DrawFixedMonsters(spriteBatch, elapsedSeconds);

    DrawChests(spriteBatch);

    The modifications that I made are in the DrawParty() method where it figures out where the following characters should be in relation to the leader.  Take a look and let me know if you find anything in there.

    Hosting a codeplex project for the Boston XNA group at http://www.codeplex.com/BostonXNA/.

  • 07-07-2008 12:30 PM In reply to

    • cbowen
    • Top 10 Contributor
      Male
    • Joined on 07-07-2008
    • Massachusetts
    • Posts 7

    Re: Realistic follow the leader in the RPG starter kit

    That's great stuff!  Thanks for taking the time not just to extend the game, but to get it on CodePlex so others can see it.

    Stay tuned with the user group - Michael and I are talking about potentially focusing on the RPG kit for a while and continually extending it over the course of a number of meetings (having members show the cool ways they're able to improve the game.)

    BTW, saw this very cool Zune-based XNA RPG.  There don't seem to be any downloads or code availabe just yet though:

          http://www.valgard-zune.blogspot.com/

    -Chris

     

    Filed under:
  • 07-26-2008 8:00 AM In reply to

    Re: Realistic follow the leader in the RPG starter kit

     I've checked in an update to the rpg on codeplex with a follow the leader implementation ( this is really a basic implementation )

    Ideally you would want to make another class (PartyMember) and have thier movement/position code in there

    anyway the code I implemented Is like i said really basic and I also didn't go through the save/load code to make it so that when you save a game it saves/loads the party members and breadcrumbs (previous party Leader positions) also.

    so as a result  1) if a game is saved while playing for a while the party will take a few seconds to sync upto the leader, and 2) if a game is loaded from the first execution all party members will start on the same tile as the party leader.

    1 is easily solved I think by resetting the breadcrumbs List when the session is re-created.

    2 would need to be solved by saving the breadcurmbs and reloading them (I might look into this a little further this weekend)

    Also I've noticed that the party members get drawn on top of the leader when they are walking over each other. (this may be solved by drawing the party from the last positon to the first (leader) position )

     

    Filed under:
Page 1 of 1 (5 items) | RSS
Powered by Community Server (Non-Commercial Edition), by Telligent Systems