Hola! I have been pondering the answer to this problem, and that is: how do I make a working moving platform that, if the mc is upon it, he will move with it?
Please, if you can, end my confusion :crazy:. Thanx!
-elPooter.
P.S. I think it is called a “platform engine” or something…
Do u just mean one that goes up and down? like an elevator? cos thats not very hard, i’ll give u some code if u want it (i think i’ve done it before anyway!)
Well i’m not sure how u’d do it between mcs, i’m not very good at passing variables around, i like to do everything in the main timeline (which i’m assuming ur not) so in the elevator (u know how to make it go up then down?) have with all ur other code under
onClipEvent(enterFrame){
//asuming char_mc is the instance name
//of ur char
if(hitTest(_root.char_mc){
_root.char_mc.onElevator = true;
//is registration is on the bottom of elevator
_root.char_mc.elevator_y = this._y;
} else {
_root.char_mc.onElevator = false;
}
then have on ur char mc (i might need to see what ur doing for moving him around)
onClipEvent(enterFrame){
if(!this.onElevator){
//normal function like jumping
//around moving etc
} else {
//asuming registration is at bottom
//of mc
//width part is to make it ontop of elevator
//which u might not need (depending on how thick
//it is)
this._y = this.elevator_y+_root.elevator_mc.width2;
//then u might want him to be able to jump off
//so put that here as well
}
}
anyway thats how i’d do it, theres probably a million different ways u would do it, so if anyone else would like to post what they’d do it’d help
If the player’s origin is touching the top side of the platform then the player is moved by the speed of the platform in the direction of the platform. In this way you would need to have the platform move by code rather than by tweening. Also,movement caused by the platform is in ADDITION of the movement that the character would normally make (so the character can still run around and jump and stuff)
I wasn’t suggesting doing the movement of the platform by tweening, but i said i assume he knows how to make a platform go up and down, i guess i wasn’t 100% clear on that.
It depends what game u play whether moving on a platform lets u jump and move around and stuff, but as soon as he jumps off the platform, the hittest would become false and he could move.
Also in your code do u have a line that says where the ground is, cos u could just make it a variable, then change the variable to what the elevators _y is if he’s on the elevator (if that made sense!)