Faybs

Warper
Member
Joined
May 19, 2021
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMZ
Hello!

I have a problem. For the first time I need to use script commands in my game in order to make it work efficiently. My problem is: I need to set a Move Command from an event which Event ID has (already) been stored in a variable (let's assume Var:20). And I want the move command to be: Go towards X, Y (coordinates, that also have been stored in a variable each) (let's assume Var:21 and 22).
So (again) I know how to store variables, but the issue is to make a line that takes the Event ID (var:20) go towards (var: 21), (var 22)
Please help me out! I would be very grateful! I am open to every suggestion!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,289
Reaction score
8,364
First Language
German
Primarily Uses
RMMV
if that should happen on any map with any obstacles, then it needs more than just a few mathematics to determine direction - it would need a pathfinding script for the event to find its way around the obstacles to the position.

so you need to find a plugin that enables such a pathfinding script command, and then it completely depends on what functions that plugin offers.
 

Faybs

Warper
Member
Joined
May 19, 2021
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMZ
if that should happen on any map with any obstacles, then it needs more than just a few mathematics to determine direction - it would need a pathfinding script for the event to find its way around the obstacles to the position.

so you need to find a plugin that enables such a pathfinding script command, and then it completely depends on what functions that plugin offers.
That is true, but in my case I have no obstacles. To make it easier, I would like to be using the command that is used in the Movement command editor, "Move toward player".
If this is not possible then, I can make the calculations on my own, but therefore I would need a simple command movement such as "Move Down" or "Move Up".
But you have to consider that the event ID that will be moved is defined by a variable (20).
So if you could give me a formula (Script) that solves this problem I would be very grateful. :)
 

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
554
Reaction score
353
First Language
English
Primarily Uses
RMMV
Faybs, do you know for a fact that there won't be any obstacles in the way? As that makes it significantly more complex if so.
 

Faybs

Warper
Member
Joined
May 19, 2021
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMZ
Faybs, do you know for a fact that there won't be any obstacles in the way? As that makes it significantly more complex if so.
Yes for sure I can design it that way. So what would be your propositions?
 

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
554
Reaction score
353
First Language
English
Primarily Uses
RMMV
Yes for sure I can design it that way. So what would be your propositions?

In that case, you're dealing with a basic formula - "the difference between two points".

Do this:

x distance to walk = end x - start x
y distance to walk = end y - start y

Positive values mean you walk right/up, negative values mean you walk left/down.

If you move across, then vertically, then you'll reach your destination, but with a right-angled path.

There are various algorithms you can use to "draw a direct line" from one point to another on a pixel grid.

One thing you could do is randomly choose to move 1 space horizontally/1 space vertically, reducing the amount you need to move each time, so you'll always get a sort-of-diagonal line to your destination.

What sort of effect are you looking for? What's doing the movement, and what are they trying to do?
 

Faybs

Warper
Member
Joined
May 19, 2021
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMZ
In that case, you're dealing with a basic formula - "the difference between two points".

Do this:

x distance to walk = end x - start x
y distance to walk = end y - start y

Positive values mean you walk right/up, negative values mean you walk left/down.

If you move across, then vertically, then you'll reach your destination, but with a right-angled path.

There are various algorithms you can use to "draw a direct line" from one point to another on a pixel grid.

One thing you could do is randomly choose to move 1 space horizontally/1 space vertically, reducing the amount you need to move each time, so you'll always get a sort-of-diagonal line to your destination.

What sort of effect are you looking for? What's doing the movement, and what are they trying to do?
So my goal is to be able to move a character automatically from one point to another. Basically that when the player tells him to go there the event (might be an animal or person) follows him.
I just need what kind of script you would use, because I am sure that I can manage basic calculations. I don't know how to script but, to me, it should sound like this:

Event_ID($gameVariables.value(20)).step_toward($gameVariables.value(21),$gameVariables.value(22))

And since I am new to scripting I have no clue where the problem is. Please help me out. ^^'
 

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
554
Reaction score
353
First Language
English
Primarily Uses
RMMV
Ah if you want to do it in javascript, someone will need to come along who happens to be better at that than I.
 

Latest Threads

Latest Posts

Latest Profile Posts

E7DsT3VXsAInVpu

working on my avatar, because i couldn't stand looking at it anymore :D
still not finished though...
alpacaraptors = love!
''Finds icons that fits the game you're making'' Only covers 20% of what you need :p
I'm very manic-y right now. I didn't sleep and I wanted to get a bunch of stuff done, but didn't get anything done except the bare bones concept for a POSSIBLE game.
And I can't sleep now because I'm probably gonna be hanging out with my brother and I gotta discuss a bunch of BroCoG (our game group) junk with him plus it's far to late to sleep NOW.
poppetQuestBarryApproaches.jpg
While I wait for judging, I decided to start adding more "friends" to my attic. :LZSgrin:

I swear I need a whole sound pack of menacing squeaky toy noises. :kaoswt:
I can't believe I actually managed to stay motivated for the whole Game Jam duration (1 month!), definitely will be taking a break after this :0

Forum statistics

Threads
113,585
Messages
1,076,005
Members
147,568
Latest member
dnelson83
Top