PDA

View Full Version : Walking and Jumping Through Objects



Fieldrin
02-23-2010, 10:05 AM
Hello everyone, I'm new to Novashell and this is my first post.

I've looked around the forum a bit, and I haven't seen anything that answers my question, which is:

How do I create an object that the player can jump on top of, but also walk past or jump up through?

I want to be able to make a ledge that you can jump up onto from underneath, but also be able to walk past it where it normally would stop you.

I'm not much of a programmer, so I appreciate any help I can get.

-Fieldrin

Seth
02-24-2010, 12:28 AM
Hi Fieldrin,

That's a very good question. Originally, in the TreeWorld example, the hanging platforms over to the right DID work this way, but after I replaced the physics system with Box2D I was too lazy to go back and fixed those platforms to be 'one way solid' again.

It's harder to do now - in the old system you could examine each collision in script and say YES or NO to allow it or not, and it was simply a matter of examining the angle of movement.

But now.. uh... hrm.

I think a method that would work is to act like the ent_brick.lua and listen for collisions, and check which direction the player is moving in and change the solidity of the platform to match.

If he's moving UP, do this:SetCollisionCategory(C_CATEGORY_PLAYER, false); and if not, do this:SetCollisionCategory(C_CATEGORY_PLAYER, true) so he collides with it.

The only thing that bugs me with this strategy is it wouldn't work correctly with multiple players at once, or enemies that could jump up through it. But, most games don't require that so maybe it's ok.

Enemies on the platform wouldn't fall off as we're only adjusting its collision properties with players specifically so that part is ok.

I'm a bit busy right now but hopefully I'll go add that to TreeWorld at some point.

Fieldrin
02-25-2010, 09:36 AM
Thanks for your quick reply. :)

Is it possible to set collision on and off for an entity by name? And would that allow two players to land on a platform they jumped through?

-Fieldrin