Jump to content
Sign in to follow this  
twiceincarnate

tutorial Auto-walk; auto-magically walk down a road at the press of a button!

Recommended Posts

Auto-walk

 

This is my first attempt at a tutorial, have a few more planned but please tell me how I could improve it or where I can clarify.

 

Please find attached a basic demo of the Auto-walk demonstrating the features and showing the eventing in detail.

 

autowalk demo (dropbox link)

 

Basic premise -

 

Using eventing a some knowledge of script calls (no scripts needed) you can have a common event that allows for the player characters to follow a road or a path 1 tile wide in any shape or path that you have drawn it - at the press of a button. This was inspired by the Witcher 3 where, if you hold down a button when riding your horse it will automatically follow the road.

 

I have been making big maps - really big, and on these maps I've been drawing in roads, but it gets a little tiresome to explore these maps by moving around holding a direction. I'd been looking for a script that could do something like this but with no luck. Luckily, with a bit of rooting around and thinking me and my bro managed to figure out something that works for us, and might work for you.

 

Example of a map with road drawn on -

 

 

KWaXIXt.png

 

 

How it works -

 

At the press of a button your character will follow a path, stopping when you press a directional button or at the end of the road or at a crossroads. you can draw any kind of road 1 tile wide on a map of any size and it should work.

 

The only script I've used is yanfly's button to common event, but it is not necessary to get auto walk working, only for convince. you do not need the script but it does make auto-walk simpler.

 

link to script

 

What you'll need -

 

1. You will need to create 3 blank events per map, and they will all need to have the same id - the simplest way is to have them be event 1, event 2, and event 3. They should be blank and have the through box ticked.

 

2. You will need 1 common event slot - everything will be handled here.

 

3. For the terrain that you want the player to autowalk on you will need to go to the Database, Tilesets, Terrain Tags and modify the number of the terrain to something that you aren't using for any other terrain. I've set roads to terrain tag 5 and am not using it for any other terrain other then roads.

 

 

BOjL0cK.png

 

 

Important to note

 

I've discovered that at a normal move speed the auto-walk does not seem to work all that well - I've found that the max move speed that it works at is about 3.6. you can use a simple script call to alter the move speed -

 

$game_player.instance_eval("@move_speed = 3.6")

 

I've made it so the common event in the demo changes the players move speed while auto-walking, but this is not pictured in my screen shot below.

 

Auto-walk Common Event

 

In the spoiler you can see the whole common event that I'm using - there are a few bits that may be redundant but it more or less works (lol)

 

 

QnL8W40.png

 

 

The initial conditional branch is to make sure that the event does not proceed if the player is not on a road - this prevents interference on maps that you do not want the autowalk to function on. you can similarly use a switch or variable or map id for the condition.

 

Below that starts the loop. in the demo I've included a script call to change the players speed to 3.6 - the max speed I've found that the auto walk works at properly - any faster and is doesn't seem to turn correctly. you might be able to figure out how to get it working better than me xD

 

At the start of the loop you'll see a conditional branch by player direction - this then uses a script call to place events 1,2,3 respectively in front, and to either side of the player. this needs to be repeated for each event and for each possible direction the player can face.

 

Just below there is a nested conditional branch that reads the terrain tags of events 2 and 3 and calls a move route for the player to wait for one frame. this makes the player come to a halt at crossroads or where multiple roads intersect.

 

Below that is the conditional branch reading the terrain tags of event 1 - the event in front of the player. this simply reads that if the terrain tag is 5 (a road terrain) the player preforms 1 step forward, skipping if unable to move.

 

In the conditional branch, as well as in the conditional branches that follow you'll see I've included nested conditional branches that in the case of any direction being pressed the loop will break - this is so at any point during the auto-walk you can resume control of the player character.

 

In this conditional branch there is a jump to label: loop, taking you back to the label at the top of the common event at the start of the loop - this is necessary so that during the auto-walk the player movement prefers going forward to turning at junctions.

 

The next two conditional branches are identical, reading the terrain tags of events 2 and 3 - in the case of event 2 it would turn the player character right by 90 degrees and step forward, in the case of event 3 left by 90 degrees and a step.

 

You can see that I've included a wait for 5 frames after each - that is so the move has time to execute / be registered before the event loops.

 

Nested in the conditional branches all the way to the bottom are repeated the conditional branch to break the loop by direction pressed - I'm not sure if all of them are entirely necessary, but I've included them because it was working for me xD.

 

At the bottom, after the look (not pictured) is a script call to return movement to normal speed.

 

Finally -

 

The common event in the demo attached differs slightly from whats pictured, and includes the yanfly button to common event script. you should be able to see it working. 

 

Well, thats about it I reckon. This is the first tutorial I've tried my hand out, not sure how helpful it might be - I was just excited at having figured out how to do something like this and thought to share it with youse all. I hope you can find something to use in whatever project you're working on here, and in the future I might try my hand at a couple of other tuts to do with mapping or variable terrain speed. 

 

Thanks for reading!

 

autowalk demo (dropbox link)

 

 

Edited by twiceincarnate

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted