Moving character in 2.5D platformer

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums

Moving character in 2.5D platformer

Postby 3DModelerMan » Mon Jul 06, 2009 1:40 am

Does anyone know of a good technique to make a player character move along the correct path? I had the level be where it just goes straight to the right. Now I'm redesigning it and it goes to the right then turns and goes back to normal then loops around (and there will be more of this later). I can't just move straight along the X-axis like I normally do.
Thanks :D .
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModelerMan/replicator#tipjar
User avatar
3DModelerMan
 
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Postby Virion » Mon Jul 06, 2009 5:11 am

i don't really understand... :?:
User avatar
Virion
 
Posts: 2102
Joined: Mon Dec 18, 2006 5:04 am
Location: Malaysia

Postby JP » Mon Jul 06, 2009 7:10 am

yeah not sure i understand either... maybe a picture would help?

what's your control scheme? it seems that you're going to be changing the axis the player moves along, will the controls change too?
Image Image Image
User avatar
JP
 
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK

Platforms

Postby 3DModelerMan » Mon Jul 06, 2009 2:56 pm

It's a side scroller rendered in 3D like Kirby 64.
This is the path that he follows now, the red line shows his path and the black is platforms.
Image
And this is what it should be.
Image
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModelerMan/replicator#tipjar
User avatar
3DModelerMan
 
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Postby Virion » Mon Jul 06, 2009 3:10 pm

oh... he means something like this: http://www.youtube.com/watch?v=AlsH_AH7CDs

that's the thing that i've been always wondering as well.
User avatar
Virion
 
Posts: 2102
Joined: Mon Dec 18, 2006 5:04 am
Location: Malaysia

Postby trivtn » Mon Jul 06, 2009 3:26 pm

I think Starcraft game is good example all he want.
There's something is fantastic, there's nothing is absolute.
User avatar
trivtn
 
Posts: 121
Joined: Tue Jan 17, 2006 12:30 pm
Location: Viet Nam

Postby JP » Mon Jul 06, 2009 5:14 pm

Might have to use some kind of waypoint graph to follow
Image Image Image
User avatar
JP
 
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK

Postby Dorth » Mon Jul 06, 2009 7:03 pm

The way I've saw this coded before was as a line of node. Every point on the movement axis is either a node or in-between 2 nodes. You then only have to keep track of progression on said line to know your orientation. Look at heightmap, it'll give you some help.
Dorth
 
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Hmmm

Postby 3DModelerMan » Mon Jul 06, 2009 8:29 pm

Yeah that could be a good way. Would a trail of flat planes work so that I could move the character forward and the rotation of the character changes depending on the normal the raycast hit? Or is that inefficient?
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModelerMan/replicator#tipjar
User avatar
3DModelerMan
 
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

I tried

Postby 3DModelerMan » Sat Jul 18, 2009 2:31 pm

I tried to figure out an implementation for this.
Code: Select all
if ( !path.empty() )
  {
   //Store Pingy's bounding box.
   aabbox3df pingyBB = mRenderMesh->getTransformedBoundingBox();
   vector3df lastPoint;
   vector3df currPoint;
   vector3df nextPoint;
   //Loop over list
   for (int i=0; i<path.size(); ++i)
   {
    //Check if point has been reached.
    if ( pingyBB.isPointInside( path[i]->getPosition() ) );
    {
     //Set the path points.
     if ( path[i-1] != NULL )
     lastPoint = path[i-1]->getPosition();
     if ( path[i] != NULL )
     currPoint = path[i]->getPosition();
     if ( path[i+1] != NULL )
     nextPoint = path[i+1]->getPosition();
     //Check for what side pingy is on.
     //=============================================
     if ( mRenderMesh->getPosition().X < path[i]->getPosition().X )
     {
      //Set new rotation.
      //=============================================
      vector3df toNext = mRenderMesh->getPosition()-nextPoint;
      vector3df newRot = toNext.getHorizontalAngle();
      mRenderMesh->setRotation(newRot);//(Or the controller empty)
      //=============================================
     }
     else
     {
      //Set new rotation.
      //=============================================
      vector3df toLast = mRenderMesh->getPosition()-lastPoint;
      vector3df newRot = toLast.getHorizontalAngle();
      mRenderMesh->setRotation(newRot);//(Or the controller empty)
      //=============================================
     }
    }
   }
  }

But for some reason it crashes.
I have the first and second scene nodes put in the path already.
What am I doing wrong?
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModelerMan/replicator#tipjar
User avatar
3DModelerMan
 
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Or maybe...

Postby 3DModelerMan » Sun Jul 19, 2009 2:43 am

Or maybe this psuedocode has the basic idea?
Code: Select all
if ( pointIsInBox(playerBB) )
{
 if ( playerPos > pointPos[i] && playerPos < pointPos[i+1] )
 //rotate.

 //do other side.
}
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModelerMan/replicator#tipjar
User avatar
3DModelerMan
 
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Postby grumpymonkey » Tue Jul 21, 2009 11:11 pm

you could add invisible nodes at every turn and make the player face the direction of it for example:

Image

you can use this function to get the angle between 2 points:

Code: Select all
double PointDirection(double x1, double y1, double x2, double y2){
   double angle=0;   
   angle=(atan2(x1-x2,y1-y2)*180)/3.14;
   return angle;
}


each node has the location of the next one so when the player reaches it, he gets the position of the next one, and faces that direction
Image
User avatar
grumpymonkey
 
Posts: 222
Joined: Mon Jan 19, 2009 10:03 pm
Location: Miami, Florida

Postby Josie » Sat Jul 25, 2009 5:14 am

Grumpymonkey is right. The best way I can think of is a node-based path. You can use splines if you want it to be extremely smooth. Interpolating between the points makes everything blend together. The camera will of course be rotated to face the current point between two nodes where the character is, and the location of the camera can be determined using cross products.
User avatar
Josie
 
Posts: 44
Joined: Sat Jul 25, 2009 4:08 am
Location: Griffin, Georgia, US


Return to Game Programming

Who is online

Users browsing this forum: No registered users and 0 guests