Collision Platform Problems

Game Editor comments and discussion.

Collision Platform Problems

Postby Leeesaw » Tue Sep 28, 2010 6:33 pm

Ok so I want the player to jump through the platforms and then land on top of the platform. I made my collision so that its only the top of the platforms, but when i turn "repeat while colliding" to YES... as soon as my player touches the platform (in the middle of jumping through) it auto puts the player on top of the platform.

Please Help. :)
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Collision Platform Problems

Postby DST » Tue Sep 28, 2010 11:25 pm

Here ya go.

collision>top side>platform>repeat yes
Code: Select all
if(yvelocity>0){
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 000000, 1.000000);
canjump=1;
               }


therefore, it only happens if he's falling (or 'falsefalling' for the repeat collision+gravity that occurs when he's walking).

Assuming you are familiar with canjump? here's the draw actor from the test i performed before giving you advice...

Code: Select all
char *key=GetKeyState();
if(key[KEY_LEFT]==1){
    xvelocity=-5;}
else if(key[KEY_RIGHT]==1){
    xvelocity=5;}
if(key[KEY_RSHIFT]==1){
if(canjump==1){
yvelocity=-22;
canjump=0;
              }
                     }
yvelocity++;
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Collision Platform Problems

Postby Leeesaw » Wed Sep 29, 2010 11:16 pm

I am essentially using the same code in my game, but I did try out your code in a new scene and it has the same problem. My guess is: that if your player is halfway through a block when the velocity == 0 (essentially when gravity kicks in) then the player is placed on top of the block.

I attached a quick demo of the problem. The player shouldn't be able to reach the platforms...
Attachments
collisionTest.exe
(1.38 MiB) Downloaded 70 times
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Collision Platform Problems

Postby DilloDude » Thu Sep 30, 2010 2:06 am

I encountered this problem before. What I ended up doing was this:
Code: Select all
    double yv = yvelocity;
    if (yv > -1) // if we're not moving down, we shouldn't collide.
    {
        double ychange;
        PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_SPECIFIED_MASS, 1, 1, 1, 1); //apply the physics
 
        ychange  = abs(yprevious - y); //how much has our y position changed?
        if (ychange > yv) // if we've moved further than our initial yvelocity, we shouldn't have collided
        {
            yvelocity = yv; //reset our yvelocity
            y = yprevious + yvelocity; //reset our y position
        }
        else //otherwise, the collision was correct
        {
            oG = 1; //we adjust our onGround variable, and do any other actions we would do on the collision
        }
    }
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: Collision Platform Problems

Postby Leeesaw » Thu Sep 30, 2010 4:17 am

Sigh... still not working. I tried your code in various ways and its still having all sorts of issues.

Though I think its probably more to do with my own messy code... Ill play around a bit more.
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Collision Platform Problems

Postby Leeesaw » Thu Sep 30, 2010 4:49 am

Here is what is going on now...
Attachments
collisionTest2.exe
(1.38 MiB) Downloaded 86 times
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Collision Platform Problems

Postby DST » Fri Oct 01, 2010 1:18 am

I'd suggest changing the rate of jump for your character, or changing the levels of the platforms. The timing of your game is probably the most important factor.

in any game, no matter how professional, there are limits to the scripting. Almost all of the time, the gameplay itself is adjusted to meet the requirements of the engine.

Remember how older games make you invincible for a second when hit? Just imagine what would happen if they didn't, and you got stuck between an enemy and an enemy statue, bouncing back and forth, getting hurt until death? the invincibility was a method to overcome limitations of the engine.

Btw, i always wanted to tell the world SHINOBI on the NES sucked big because you could get bounced between two enemies until death. I hope the company that made that version of Shinobi feel bad. It was a terrible version of a great game.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Collision Platform Problems

Postby Leeesaw » Fri Oct 01, 2010 3:40 pm

Thanks for all the help everyone :)

SO what I ended up doing:

I made an actor at the feet of the player (an almost completely transparent box) and named it feetCollision.

I set it so the feetCollision is parented to the player. If the feetCollision is colliding with the platform then oG=1;

and then if the player is colliding with the top of platform:
Code: Select all
if(yvelocity>0)
{
    if (oG ==1)
      {
          PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 000000, 1.000000);
           canjump=1;
        }
 }


This still leaves 2 problems.

If my player is standing on one platform... and their head (or any part of their body) touches another platform this will cause the player to jump up to the higher level.
To solve this im going to make my platforms a bit differently than I have. Instead of one giant platform actor im going to make a couple individual types of platforms (2 blocks across, 3 blocks across,etc) and then clone them. I think this will make the placement of platforms much much easier anyways.

The other problem is if my player is falling really quickly the feetCollision doesnt trigger and the player will pass through the platforms. Im not sure if there is a great way to fix this... for now im going to leave it and simply make sure that the ground actor isnt dependant on feetCollision.


Ok so that is how I hacked it together. Games are all smoke and mirrors anyways. If anyone has a better solution let me know.
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Collision Platform Problems

Postby DST » Fri Oct 01, 2010 10:43 pm

1. Cap the max yvelocity of your player. For example, player>drawActor>

if(yvelocity<10){
yvelocity++;}

2. on the collision detection, use maxvelocity +1 as your minimum.

For instance, you can ask your collision box to respond if it is within11 pixels of where player should be; or you have a collision box 11 pixels tall, or whatever. Mathematically plan it so that player cannot fall through platform at high velocity.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron