RPG Maker Forums

Good time of day to you all!


Basically, what I'm looking for is a script that will "rotate" my character before moving. By "rotate" I mean that if, for example, the player is facing up and I move down, I want my character to first turn top-right, right, bottom-right, and only then down.


So the algorithm I need is as follows:


if pressed button once ->
set_direction(top-right)
wait
set_direction(right)
wait
set_direction(bottom-right)
wait
set_direction(down)
if keep pressing button ->
move


I've been struggling with this for a few days now, and the only solution I came up with, involves a counter. Here is a small fragment:


case Input.dir8
...
when 0, 5
@turn_flag = 0
when 1 # down
...
if @prev_direction == 9 # up
if @turn_flag == 0 then set_direction(7) end
if @turn_flag == 3 then set_direction(2) end
if @turn_flag > 6
set_direction(Input.dir8)
move_diagonal(6, 2)
@prev_direction = Input.dir8
end
end
...
@turn_flag += 1
end


The problem with this solution is that if I release the button before the counter ticks to 6 (like in the example above), the character will not fully rotate in the desirable direction.


I've tried using wait functions based on Fiber.yield loops but they are not working properly.

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,050
Messages
1,018,548
Members
137,835
Latest member
yetisteven
Top