- Joined
- Jan 14, 2020
- Messages
- 59
- Reaction score
- 89
- First Language
- english
- Primarily Uses
- RMMV
Greetings-
I am trying to script a moving platform, that the player must try to land on.
I have the following code:
which works with the Player and events that look like:

Unfortunately, this is what happens when the player lands on the platform:
I know the problems lies with this:
and in the event:
(Map ID is defined when the map is first loaded)
I am wondering if anybody has a better suggestion to do what I am trying to achieve?
I have tried searching Google and this forum itself, but cannot find any concrete leads.
TIA!
I am trying to script a moving platform, that the player must try to land on.
I have the following code:
Code:
var Imported = Imported || {};
Imported.PE_JumpMan = true;
var PE = PE || {};
PE.JumpMan = PE.JumpMan || {};
(function($){
var JumpMan_Game_CharacterBase_jump = Game_CharacterBase.prototype.jump;
Game_CharacterBase.prototype.jump = function(xPlus, yPlus) {
let destX = $gamePlayer.x + xPlus;
let destY = $gamePlayer.y + yPlus;
let dest_event_id = $gameMap.eventIdXy(destX, destY);
let dest_region_id = $gameMap.regionId(destX, destY);
if (dest_event_id != 0) {
if ($dataMap.events[dest_event_id].meta.platform == true) {
JumpMan_Game_CharacterBase_jump.call(this, xPlus, yPlus);
$gameSwitches.setValue(12, true);
};
} else if (dest_event_id === 0 && dest_region_id === 255) {
JumpMan_Game_CharacterBase_jump.call(this, xPlus, yPlus);
$gameSwitches.setValue(12, true);
// $gameTemp.reserveCommonEvent(5);
$gameSwitches.setValue(14,true);
};
};
var JumpMan_Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
JumpMan_Scene_Map_update.call(this);
// input triggered is ok, call jump
if (Input.isTriggered(`ok`) && Input.isPressed(`shift`)) {
let jump_distance = (Input.isRepeated(`shift`)) ? 3 : 2;
let xPlus = 0;
let yPlus = 0;
switch($gamePlayer.direction()) {
case 2:
yPlus = jump_distance;
break;
case 4:
xPlus = -(jump_distance);
break;
case 6:
xPlus = jump_distance;
break;
case 8:
yPlus = -(jump_distance);
break;
};
$gamePlayer.jump(xPlus, yPlus);
};
if (Input.isTriggered() == false) {
currX = $gamePlayer.x;
currY = $gamePlayer.y;
let curr_event_id = $gameMap.eventIdXy(currX, currY);
if (curr_event_id != 0) {
if ($dataMap.events[curr_event_id].meta.platform == true) {
$gameVariables.setValue(9, $gameMap.events(curr_event_id)._x);
$gameVariables.setValue(10, $gameMap.events(curr_event_id)._y);
};
};
};
};
}(PE.JumpMan));

Unfortunately, this is what happens when the player lands on the platform:
- The player doesn't get towed by the platform.
- He gets thrown to the top left corner of the screen.
I know the problems lies with this:
JavaScript:
if (Input.isTriggered() == false) {
currX = $gamePlayer.x;
currY = $gamePlayer.y;
let curr_event_id = $gameMap.eventIdXy(currX, currY);
if (curr_event_id != 0) {
if ($dataMap.events[curr_event_id].meta.platform == true) {
$gameVariables.setValue(9, $gameMap.events(curr_event_id)._x);
$gameVariables.setValue(10, $gameMap.events(curr_event_id)._y);
};
};
};
Code:
◆Transfer Player:{map_id} ({platform_x},{platform_y}) (Fade: None)
I am wondering if anybody has a better suggestion to do what I am trying to achieve?
I have tried searching Google and this forum itself, but cannot find any concrete leads.
TIA!

