0 votes

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.

Godot version 3.2.1
in Engine by (100 points)

1 Answer

+1 vote

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

by (254 points)

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.