Jump through platform???
adamadamadamwhat
Member Posts: 21
Hello everyone. I'm looking for a way to allow my player character to jump through platforms while jumping up, and land on them while coming down. He also needs to be able to jump back down to the lower platforms - I'd like this to be done by pressing down+jump. I've been messing with it for half the day and I've still got nothing. Any ideas? Please!
Comments
http://gamesalad.com/game/play/80702
The only difference from your setting is that you only press down to go back down through a platform.
Another note is that you cannot get to the platform on the very top. It's just to show that you won't be stopped by the actor unless you're completely above it.
Let me know what you think!
A few things to consider:
The center of the actor has it's respective (x,y) coordinates as (0,0) which means if we add half of it's height, the respective value will be the same actor's top
I'm going to refer to your main character actor as "Hero"
The "Fake Platform" has the exact same position, size, and color as the real Passable Platform
Create a Game Attribute called "Hero Y"
-Inside of your Hero actor - create a Timer behavior: every - 0 seconds
-- inside the timer, change the attribute "Hero Y" to self.Position.Y - self.Size.Height /2
This will constantly update the game variable "Hero Y" to the value of the bottom of your actor.
Since "Hero Y" is a Game attribute, other actors can access it's values and respond accordingly.
-Inside of your Passable Platform actor - create a rule with this condition
---Attribute game.Hero Y > self.Position.Y + self.Size.Height /2
--inside this rule, use the collide behavior to bounce when colliding with the Hero character
-Inside of your Passable Platform actor - create ANOTHER rule with these conditions:
---Attribute game.Hero Y > self.Position.Y + self.Size.Height /2
---Actor receives event - key - down arrow - is down
---Actor receives event - overlaps or collides - actor of type - Hero
--Inside this rule, you must FIRST DESTROY THIS ACTOR. Then, Spawn the Fake Platform
-Inside of your Fake Platform actor - create a timer: every - 0.1 seconds
--Inside the timer, Spawn the Passable Platform
--Still inside the timer but AFTER the spawn behavior, destroy the actor
Explanation:
What's happening is the platform won't collide with the Hero unless his bottom is above the passable Platform's top. When this condition is met, the platform then adds the collide behavior which doesn't allow the Hero to pass through any more.
When the player presses down on the keyboard, the passing platform is destroyed and the fake platform is spawned in the exact same position. This occurrence is not visible. Once the fake platform is spawned, the Hero does not have a collide behavior with it and falls through. A tenth of a second after the fake actor is spawned, the Passable Platform is spawned back. When it is spawned back, the Hero's bottom is already below the Passable Platform's top and falls through, allowing for this process to be repeated infinitely.
I hope this explanation helps!
Let me know if I need to clarify anything that I've put
My characters jumping/moving isnt as smooth as yours, but I followed your instructions and got it to work on a test level http://gamesalad.com/game/play/80747
I'm hoping if I keep helping out with questions on the forum that someone will let me join their team x] That, and service = warm fuzzies in my heart xD