Moving character in 2.5D platformer
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
Moving character in 2.5D platformer
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 .
Thanks .
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
i don't really understand...
My company: http://www.kloena.com
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
Platforms
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.
And this is what it should be.
This is the path that he follows now, the red line shows his path and the black is platforms.
And this is what it should be.
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
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.
that's the thing that i've been always wondering as well.
My company: http://www.kloena.com
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
Hmmm
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/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
I tried
I tried to figure out an implementation for this.
But for some reason it crashes.
I have the first and second scene nodes put in the path already.
What am I doing wrong?
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)
//=============================================
}
}
}
}
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/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
Or maybe...
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/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
-
- Posts: 222
- Joined: Mon Jan 19, 2009 10:03 pm
- Location: Miami, Florida
- Contact:
you could add invisible nodes at every turn and make the player face the direction of it for example:
you can use this function to get the angle between 2 points:
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
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;
}
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.