playMaker

Author Topic: Jump Through Platform  (Read 2465 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Jump Through Platform
« on: January 30, 2015, 07:01:03 PM »
Hi!

I make a platformer where the player can jump through the platforms. I got it working. I just wonder, what is the best way to make the player be able to jump through platforms? I use a trigger and disable the platform collider when the platform enter the trigger.

Here is what I did:
I have a Jump through platform trigger I parent to the player
In this trigger, I have 3 states.

-State 1:
Trigger Enter. I set the tag I use for the platforms and store the collider as a game object variable.

-State 2:
I have these actions:
-Wait - 0.5 sec. The time it takes before it enable the collider in the next state.
-Get Component. And I store the component in a variable. I call it Collider
-Set property. I use the variable I stored, (Collider). And disable it.

-State 3:
-Set property. Here I enable the collider again and send a finish event to state 1.

It works very well, but I discovered a problem when I have an enemy with rigid body on these platforms. When I jump through the platform, the enemy of course falling through the platforms, because I disable the collider.

So my question again is, is it another better way to do this?



Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Jump Through Platform
« Reply #1 on: January 30, 2015, 07:38:21 PM »
I think it would be better to set the player collider to trigger (or disable its collider) when detecting the platform ahead, that way the character will be able to go through the platform, and the enemy will stay on the platform.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Jump Through Platform
« Reply #2 on: January 31, 2015, 06:45:34 AM »
Hi!

So you mean instead of disable the collider of the platforms, I disable the collider of the player? I tried that and it works also very well. I just had a problem when the player check the ground. It check if it's grounded when the player jump through platforms. I just added a wait time, so it jump through before it check the ground.
I also need to be careful with the distance of the platform vertical, so the jump through trigger doesn't crash with the platform above the platform I jump through.
Or else it works very well so far. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

cloud03

  • Full Member
  • ***
  • Posts: 249
  • Viva Playmaker!
    • Milkish Game Studios Blog
Re: Jump Through Platform
« Reply #3 on: February 01, 2015, 02:12:52 AM »
You'll have to add a raycast up direction when the character jumps, but make sure it is a short length, and when it detects the ground above, disable the collider straight away, add a wait time for a very short time (perhaps around 0.1 or 0.2) before enabling back the collider, that should do the trick.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Jump Through Platform
« Reply #4 on: February 01, 2015, 08:12:38 AM »
Or else I can use a jump through trigger on the player. Also works :)

But thanks anyway. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no