XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

How to let a puppet move in an environment?

Last post 03-29-2008 12:30 AM by David Hunt. 4 replies.
  • 01-04-2008 7:23 AM

    How to let a puppet move in an environment?

    Well Nick and David, you 2 helped me alot on my previous question thx for that but now i have a new question...

    a bit more complicated but i have a landscape of DargGDK that i wanne use for a testjob and a puppet made in 3dsMax 2008. and now i want this puppet to walk on that land instead of camera viewing. is this possible and how? i was thinking instead of using the camera, let me use the puppet but idk where to start. here are the 2 images, Thx in advanced

    This is just a simple little puppet for trial version.

    Thx, Nightlife

  • 01-31-2008 9:23 PM In reply to

    Re: How to let a puppet move in an environment?

    It's possible to program anything, so I see why not? I don't anyone will tell you exactly how to do it. I mean, that's all up to you. There are plenty of useful resources on the Internet that you can find (like gamedev.net) answers to your question, and then you can figure out how to apply it on your own.

    As someone else here said: We can guide you to fish, but we won't do the fishing for you.

  • 03-28-2008 2:50 PM In reply to

    Re: How to let a puppet move in an environment?

    You would have to store a float for rotation, and a vector for position. Then whenever the user presses forward for example, you move the way the puppet is facing (based off the rotation). I can't remember the exact math for it right now, but it's a simple SIN and COS operation.

    I don't know how you've done your terrain, but if you had an accompanying heightmap, you could then position him so he looks like he is standing on the terrain properly also (even when moving up bumps, etc).

    Gamertag: Prey074
    Website: homebrewgames.co.uk
  • 03-28-2008 5:19 PM In reply to

    Re: How to let a puppet move in an environment?

    I've never used DarkGDK so the API is foreign to me, but let me explain how I would do this. First your character must have a rotation and position like Alex mentioned. The position should be the position of the bottom of the model. This is important for keeping him above ground. The rotation would be controlled by your input so that's up to your API and shouldn't be too challenging. Just get the game pad or mouse or keyboard input and translate that into a rotation for your character.

    To keep your character on the terrain what you generally do is "raycast" from the character down. I generally perform raycasts from the head even though the position is at the feet. The reason for this is because gravity may pull your character's feet through the ground so casting a ray down from there will not return a result. Casting down from the head will almost always give you a point on the ground.

    To do the ray casting, you'll need to do some trigonometry depending on the API. For instance, in the XNA framework there is a Ray structure which can detect intersections with basic bounding volumes. Then the team released a sample doing Ray-to-polygon collision sample which allows us to quickly find intersection points between a ray and a model. So it's not too bad because the XNA framework provides these methods. In DarkGDK you may have to see if the API provides such functionality otherwise you'll have to do it yourself.

    Here are a few links that might help you out if you have to do the grunt work on your own:
    http://en.wikipedia.org/wiki/Raycasting
    http://www.flipcode.com/archives/Basic_Collision_Detection.shtml


    Nick Gravelyn -- Microsoft XNA MVP
    Blog | Metacreature Games | Super Gravelyn Bros | Bloc | Next-Gen
  • 03-29-2008 12:30 AM In reply to

    Re: How to let a puppet move in an environment?

    The DarkGDK website has a pretty active set of forums that could probably help you out with answers specifically geared toward DarkGDK solutions.

     

Page 1 of 1 (5 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG