Set Event's Position from Javascript

mike7

Villager
Member
Joined
Oct 18, 2015
Messages
16
Reaction score
2
First Language
English
Primarily Uses
Does anyone how to set an event's location from a javascript command? I'm trying to get an event to follow the player's x position, but the code isn't doing anything:


$gameMap.event(84).x = $gamePlayer.x;




What's wrong with my code above or is there another way to set an event's location?
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
'x' in this instance is a function, and only returns whatever the variable '_x' is. What you need to use is '_x'. You will also need to set '_realX', as well. Otherwise the event will 'float' over to the location instead of instantly appearing there.

Code:
$gameMap.event(14)._x = $gamePlayer._x;
$gameMap.event(14)._realX = $gamePlayer._realX;
 

mike7

Villager
Member
Joined
Oct 18, 2015
Messages
16
Reaction score
2
First Language
English
Primarily Uses
Awesome! Thanks for the fast response and help! It works like a charm.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,864
Messages
1,017,056
Members
137,573
Latest member
nikisknight
Top