Jump to content


Photo

Jump through platform


  • Please log in to reply
17 replies to this topic

#1 DcoldSaviour77

DcoldSaviour77

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 26 February 2012 - 04:40 PM

Hey guys, I need help coding a jump through platform where the player can jump up from underneath and stay on top of it too.
  • 0

#2 RangerX

RangerX

    GMC Member

  • GMC Member
  • 998 posts
  • Version:GM8.1

Posted 26 February 2012 - 04:53 PM

Do you have collisions for you game already?
Because that platform is just like a collision except that it doesn't affect your player if it is having any positive vspeed.

Edited by RangerX, 26 February 2012 - 04:53 PM.

  • 0

#3 DcoldSaviour77

DcoldSaviour77

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 26 February 2012 - 05:20 PM

Do you have collisions for you game already?
Because that platform is just like a collision except that it doesn't affect your player if it is having any positive vspeed.

so would i code it like this
if vspeed>0 solid=false
  • 0

#4 RangerX

RangerX

    GMC Member

  • GMC Member
  • 998 posts
  • Version:GM8.1

Posted 26 February 2012 - 05:31 PM

Well, its if the player is having any negative vspeed then it shouldn't collide with the platform. Sorry, I did word it very badly in the other post... :/
  • 0

#5 DcoldSaviour77

DcoldSaviour77

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 26 February 2012 - 05:33 PM

Well, its if the player is having any negative vspeed then it shouldn't collide with the platform. Sorry, I did word it very badly in the other post... :/

So like this,
if vspeed<0
solid=false
else
if vspeed>0 && !place_free(x,y+vspeed){move_contact(270)}vspeed=0
would this work?
  • 0

#6 RangerX

RangerX

    GMC Member

  • GMC Member
  • 998 posts
  • Version:GM8.1

Posted 26 February 2012 - 05:37 PM

You make your character solid or not, depending you want it to collide with stuff or I'm reading you wrong?
If your solid/not solid thing works, yes you have the right condition right there (if vspeed>0). But now your character will not collide with anything when it's moving up...
  • 0

#7 DcoldSaviour77

DcoldSaviour77

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 26 February 2012 - 05:41 PM

You make your character solid or not, depending you want it to collide with stuff or I'm reading you wrong?
If your solid/not solid thing works, yes you have the right condition right there (if vspeed>0). But now your character will not collide with anything when it's moving up...

Yeah I thought of that too so I didn't put it in my main character instead I put it in the object the main character will stand on.
  • 0

#8 RangerX

RangerX

    GMC Member

  • GMC Member
  • 998 posts
  • Version:GM8.1

Posted 26 February 2012 - 05:45 PM

Just a curiosity,

Your main character is standing on something and that objet is managing some stuff for that character?
You're making a platformer game or .. ?
I was wondering why your character wouldn't be able to manage itself.
  • 0

#9 DcoldSaviour77

DcoldSaviour77

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 26 February 2012 - 05:54 PM

Just a curiosity,

Your main character is standing on something and that objet is managing some stuff for that character?
You're making a platformer game or .. ?
I was wondering why your character wouldn't be able to manage itself.

It could but I think it would be easier for only the objects I want to do this stuff and just use with() when I want things to apply to my main character. I just tried my code and it works only it's glitchy when I stop jumping in the middle of object, and he floats when he's suppose to come down. I'm making a platformer game.
Ok, he floats because I have it in the platform's step event so his vspeed is constantly 0. So I changed it to a collision event, but it's even worse with the glitching. Sometimes he'll fly up extremely fast like and if I stop in the middle of it he gets stuck.

Edited by DcoldSaviour77, 26 February 2012 - 05:59 PM.

  • 0

#10 RangerX

RangerX

    GMC Member

  • GMC Member
  • 998 posts
  • Version:GM8.1

Posted 26 February 2012 - 06:03 PM

You would need a check to see if you're still colliding with the platform. When you're not colliding anymore, turn back on the collisions.

But I get a feeling the way you're making your character is complicated for nothing. It should be quite easy to make a character that handles itself and simple collisions.
  • 0

#11 DcoldSaviour77

DcoldSaviour77

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 26 February 2012 - 06:13 PM

You would need a check to see if you're still colliding with the platform. When you're not colliding anymore, turn back on the collisions.

But I get a feeling the way you're making your character is complicated for nothing. It should be quite easy to make a character that handles itself and simple collisions.

Ok this is what I have so far.
if (mario.vspeed<0)
{solid=false}
else
{
with(mario){
if (place_meeting(x,y,smallcloud_obj))
{
 if vspeed>0 && !place_free(x,y+vspeed){move_contact(270)}vspeed=0
 solid=true
}} 
}
It still floats only when I'm touching the cloud now. I just can't get it. Should I be putting this in a Step event or a Collision event.

Edited by DcoldSaviour77, 26 February 2012 - 06:15 PM.

  • 0

#12 RangerX

RangerX

    GMC Member

  • GMC Member
  • 998 posts
  • Version:GM8.1

Posted 26 February 2012 - 06:25 PM

if(mario.vspeed<0)&&(place_meeting(x+hspeed,y+vpseed,smallcloud_obj))
{solid=false;}

This should make Mario not solid anymore and pass throught the platform only when he's going up.
Your bottom detection seems to be fine. And it looks like something you should put in a step event.

Edited by RangerX, 26 February 2012 - 06:26 PM.

  • 0

#13 DcoldSaviour77

DcoldSaviour77

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 26 February 2012 - 06:33 PM

if(mario.vspeed<0)&&(place_meeting(x+hspeed,y+vpseed,smallcloud_obj))
{solid=false;}

This should make Mario not solid anymore and pass throught the platform only when he's going up.
Your bottom detection seems to be fine. And it looks like something you should put in a step event.

It didn't work, Mario is not even solid and when I touch the top of it he skips to the bottom and he gets stuck in the middle of the cloud
  • 0

#14 RangerX

RangerX

    GMC Member

  • GMC Member
  • 998 posts
  • Version:GM8.1

Posted 26 February 2012 - 06:55 PM

I'd have to mess around in your code to truly fix it I guess.
  • 0

#15 DcoldSaviour77

DcoldSaviour77

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 26 February 2012 - 07:07 PM

I'd have to mess around in your code to truly fix it I guess.

I've been doing that. I changed the move_contact to 90 and that makes him stay on top. But now whenever Mario stops in the middle of the cloud he goes to the top. Any ideas how to make him fall back down.
This is what I have in code.
if (mario.vspeed<0)
{solid=false}
else
{
with(mario){
if (place_meeting(x,y,smallcloud_obj))
{
if vspeed>0 && !place_free(x,y+vspeed){move_contact(90)vspeed=0}
}}
solid=true
}

Edited by DcoldSaviour77, 26 February 2012 - 07:08 PM.

  • 0

#16 RangerX

RangerX

    GMC Member

  • GMC Member
  • 998 posts
  • Version:GM8.1

Posted 26 February 2012 - 07:19 PM

if (place_meeting(x,y,smallcloud_obj))
{
       if vspeed>0 && !place_free(x,y+vspeed)
       {move_contact(90)
        vspeed=0;
       }
}
solid=true;
}


First off, if you are place meeting it means you are also !place_free. What's the use of the place_free check then?
Also, I don't understand how a move_contact_solid moves you OUT of the platform. There's a solid on top of the platform ??
  • 0

#17 DcoldSaviour77

DcoldSaviour77

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 26 February 2012 - 07:29 PM

if (place_meeting(x,y,smallcloud_obj))
{
       if vspeed>0 && !place_free(x,y+vspeed)
       {move_contact(90)
        vspeed=0;
       }
}
solid=true;
}


First off, if you are place meeting it means you are also !place_free. What's the use of the place_free check then?
Also, I don't understand how a move_contact_solid moves you OUT of the platform. There's a solid on top of the platform ??

I think the move_contact moves me up until there is a contact with the bottom of mario. That's why when it was 270 it was moving me down. i think. I'm not 100% sure.
  • 0

#18 RangerX

RangerX

    GMC Member

  • GMC Member
  • 998 posts
  • Version:GM8.1

Posted 26 February 2012 - 08:08 PM

Ok, it's your object under Mario that is doing the move contact solid...
Again I feel your thinking is complicated for nothing. Why couldn't be Mario itself doing all it needs to do? It's needlessly more complicated to have an object under him...
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users