This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

When loading the scene, the position of nodes are not loaded because main scene has default object properties

 get_tree().reload_current_scene() 

when I reload with this or load and queu.free() my previous scene;

all positions although loaded, not works. How can I reload or load the scene and have my load.tres file work?

get_node("Player").transform.origin = Vector3(48.672, 128.565, -31.473)
var yu : Resource = load("res://Scenes/Player/Player.tscn")
in Engine by (193 points)
edited by

How are you saving the positions? Are you storing it as a variable then assigning it or saving it to a JSON or config file?

I save them in .tres file and then read them:
Vector3(a, b, c)

    var mm3 = save_game_values.data2["%s" % node.name].values()[0]
    get_node(node.get_path()).transform.origin = Vector3(mm3[0], mm3[1], mm3[2])

.tres files are used for resources like materials, skyboxes etc. As far as I'm aware there isn't a way to save types to a tres file, your code is getting a value from a dictionary and storing it in an array. The floats in a Vector3 are a struct, not an array so instead of mm3[0] it will be mm3.x

Thanks that will nicely do

Can you reply this as an answer so I can mark it as resolved?

Sure. I've just clarified it a little more as well.

1 Answer

+1 vote
Best answer

.tres files are used for resources like materials, skyboxes etc. As far as I'm aware there isn't a way to save types to a tres file unless it's a custom resource.
Your code is getting a value from a dictionary and storing it in an array. The floats in a Vector3 are a struct, not an array so instead of mm3[0] it will be mm3.x

Basically it's Vector3(struct{float x, y, z}) not Vector3([1, 2, 3])

by (3,259 points)
selected by

https://godotengine.org/qa/user/Magso Thanks Magso You have helped me so much!

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.