Page 1 of 1

PLatform Game Help Request

PostPosted: Tue Jun 14, 2011 9:13 am
by foleyjo
Hi all

Just after a bit of help. I'm currently looking at platform games and am having a bit of trouble with the collision detection of the floor and was wondering if someone could take a quick look and tell me what I'm doing wrong.

I'm going for a Jet Set Willy type game so the player must be able to
- Walk left to right and jump.
- Walk through platform and has the ability to jump up through them to land on them
- walk diagnoly up and down ladders

So far the player keeps getting his feet going through the floor
player ignores the steps
When jumping up to a platform he ends the jump early when he collides with the platform

Tiles1 = Tiles that the player can not pass at all
WalkTiles = Tiles the player can walk on
StepTiles = Tiles used for stairs that the player can walk up and down
DeathTiles = Tiles that kill

I apologise in advance for any messy code and lack of comments

Re: PLatform Game Help Request

PostPosted: Tue Jun 14, 2011 12:46 pm
by Jagmaster
I have a quick answer to one of your problems.

Collision -> top side of walk tile.
Code: Select all
if(yvelocity >=0)
{
PhysicalResponse(blah, blah, blah)
}

This will only make the guy land on the platform if he is falling.

I didn't download your example yet, but this might be of use.

Re: PLatform Game Help Request

PostPosted: Tue Jun 14, 2011 4:26 pm
by savvy
also try jagmasters code plus this for added specials..

Code: Select all
if(yvelocity >=0&&y<collide.y-(height/2))
{
PhysicalResponse(blah, blah, blah)
}

the added && will make sure the player is its own height above the platform.

Re: PLatform Game Help Request

PostPosted: Tue Jun 14, 2011 7:01 pm
by Jagmaster
Yes, that would be handy for a tall character. :)

Re: PLatform Game Help Request

PostPosted: Wed Jun 15, 2011 11:40 am
by foleyjo
Thanks guys.

That works for the jumping and landing

but.... (and theres always a but :( )

The players characters head sometimes needs to pass through ledges.

Now using the technique you provided when the players head touches a ledge he automatically jumps up to the top of the ledge.

Re: PLatform Game Help Request

PostPosted: Wed Jun 15, 2011 2:29 pm
by Jagmaster
Try making the player a parent of a region actor and give all events to this actor instead of the big animation guy.
Also, I like to add a solid actor to the edge of the un-solid actor.

Here is an example I got to work.
sample.ged
(4.71 KiB) Downloaded 81 times

Re: PLatform Game Help Request

PostPosted: Wed Jun 15, 2011 3:36 pm
by lcl
savvy wrote:also try jagmasters code plus this for added specials..

Code: Select all
if(yvelocity >=0&&y<collide.y-(height/2))
{
PhysicalResponse(blah, blah, blah)
}

the added && will make sure the player is its own height above the platform.

That won't work with tile actors.

Re: PLatform Game Help Request

PostPosted: Wed Jun 15, 2011 4:27 pm
by foleyjo
lcl wrote:
savvy wrote:also try jagmasters code plus this for added specials..


That won't work with tile actors.


LCL - Why not? It appears to be working?

Jagmaster - thanks again for that seems to do the trick. So the player now walks on platforms as he should and jumps correctly.

Just need to work out how to make him go up and down steps.

I'm including the update .ged file with the changes made from here

Re: PLatform Game Help Request

PostPosted: Thu Jun 16, 2011 12:47 pm
by lcl
It won't work with tile actors because collide.y means collide actors (your land actors) y position.
And tile actor has one y value and if tiles make platforms at different y positions the collide.y value is still the same, the whole tile actors y.

Re: PLatform Game Help Request

PostPosted: Thu Jun 16, 2011 1:04 pm
by foleyjo
I see. I think I have just come into that problem with steps. It explains the mad results I was getting.

But for the floor platforms it appears to be working. I'll probably run into problems though.
Is there anything you can suggest as an alternative?


On a different note I got my character walking up and down steps by using

collision left/right of steps
y -=10;

Re: PLatform Game Help Request

PostPosted: Thu Jun 16, 2011 1:45 pm
by Jagmaster
For me, I just skip the &&collide.y part. In the if statement, make sure the yvelocity conditional statement is twice as much as your gravity.
Code: Select all
if(yvelocity=gravity*2)
{
//
}

this will not work if you set yvelocity to 0 upon collision.

For stairs, I'm not sure if it's possible to make an actor go through the bottom and land on the top because you need it to collide on all sides.
A simple method would be:

1- make a dummy actor that looked like stairs.

2- make a tile that is a right triangle and set visibility state to don't draw but allow elements.

3- possibly make your "player armature" look like this
armature.png
armature.png (212 Bytes) Viewed 1559 times
and make it the size you want.

Re: PLatform Game Help Request

PostPosted: Thu Jun 16, 2011 4:05 pm
by foleyjo
Again thanks.

I've changed things about and now can walk around and walk up and down stairs (though haven't used the jagmaster method ..yet)

It's not perfect but it is getting there. At least he has stopped falling through the floor.
I'm going to mess about with things and see what difference it makes.