0 votes

I'm making a Pokemon type game and was wondering that after my battle, how do I make my character spawn back to the location of the encounter instead of the main location of the scene which is what happens when I use the change scene function

in Engine by (12 points)

what part of this are you not sure how to do? Is it saving the position, or making the player spawn at that position or what? What do you have so far?

1 Answer

0 votes

I've tryed to make a pokemon-like some time ago and implemented like this:

I created a scritp called Global and put on autoload.
here is the script:

extends Node

var root
var world_scene

func _ready():
    root = get_tree().get_root()

func change_to_battle(path: String, enemy: Enemie):
    var new_scene_res = load(path)
    var new_scene = new_scene_res.instance()
    world_scene = get_tree().get_current_scene()

func back_to_world():

The back_to_world is just a method that I used to do some things when the player comes back like remove the enemy of the scene.
The arg path contais the path to the battle scene and the arg enemy contain the data of the enemy for battle.

Whent the player collides on enemy just call Global.change_to_battle(...)

P.S.: That code makes the scene of level continue in the memory and consuming memory. For sure that is not the best way, but is the easyest way that i found when i coded the project...

by (171 points)
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.