Modifying kids can code procedural generation tutorial to use point and click movement

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TheJollyReaper

I want to modify Kids Can Code’s Tutorial (github) to have the player move to the center of the rooms when you click on them (the rooms), instead of having the current arrow key based movement.

In my own code, I’ve already figured out how to make the rooms clickable and how to get the position I want to move to. I don’t know where to go from there though.

I have very minimal understanding of Astar, any help in getting this working would be appreciated.

:bust_in_silhouette: Reply From: cascas

Simply set the global_position of the character to the position you want to teleport it to.
$Character.global_position = click_position

The reason I didn’t want to go with this solution initially (I guess I should have mentioned that) is because I only want the player to be able to travel to connected rooms. My idea was that if the player was still moving instead of teleporting, I could set up “bubbles/radars” in each room to detect when the player was passing and stop them.

I did end up doing what you suggested, I covered each room with a button that teleports the player to the center when clicked on. Enabling/disabling teleportation to a room should be easy, but I still have to figure out how to detect which rooms are directly connected to the room the player is.

TheJollyReaper | 2021-01-23 20:02