jumping from one moving platform to another moving platform
Hi,
I'm trying to work out how to get my player to "stick" to moving platforms when jumping across multiple moving platforms.
Here's how I'm implementing it.
Global attributes:
activeMovingPlatformID
activeMovingPlatformX
activeMovingPlatformY
playerX
playerY
moving platform attributes:
myID
myPositionX
myPositionY
moving platform behaviors:
1. if collide with player,
change attribute(game.activeMovingPlatformID to self.myID)
else,
change attribute(game.activeMovingPlatformID to 0)
- if game.activeMovingPlatformID = self.myID,
contrain attribute(game.activeMovingPlatformX to self.myPositionX)
player behaviors:
1. if collide with moving platform,
constrain attribute(self.positionX to game.playerX)
level rules actor behaviors: (a third actor that handles all scene stuff)
1. if activeMovingPlatformID != 0,
constrain (game.playerX to game.activeMovingPlatformX)
It all works pretty well but here's the issue I'm having:
when the player jumps from one moving platform and lands on a second moving platform and player's linearVelX = 0, meaning the player lands straight down (not moving left or right at all) the playerX is momentarily still constrained to the first moving platformX and is launched off the second platform usually to the player's doom or sometimes lodged in a wall.
but when the player lands on the second moving platform with some kind of linearVelX != 0, then everything works perfectly well. It seems as if game.activeMovingPlatformID is not updating fast enough with the second moving platform's self.myID but I can't be sure.
Any insights would be greatly appreciated!
Thanks
ps. heres a link to a couple of levels of the game I'm developing arcade.gamesalad.com/games/128031
Comments
I think you may be over complicating it. It's should just work with the built in physics. Do you have drag and collision on?
Collision yes, drag no. I've not used drag at all so I'll play with it a little and see what I can do. Thanks for the input.
Like Balls? Then click here! We've 100 coming soon