Works well: msg.post(url, “set_parent”)
Works badly: go.set_parent(url, nil, true)
What happens?
After call go.set_parent on child gameobject with nil parent and keep_world_transform, detached gameobject position was wrong.
You can see in the attached minimal project when click on the game window.
SetParentTest.zip (6.8 KB)
You have the following in your code:
msg.post("go2", "set_parent") -- Works well
--go.set_parent("go2", nil, true) -- Works badly
If you check the documentation for the set_parent
message you see that the default value of keep_world_transform
is 1 (true).
If you check the documentation for the go.set_parent()
function you see that the default value for keep_world_transform
is false.
This difference in how keep_world_transform
is handled explains why you get different results when posting a message and calling the function.
I read the documentation, so the 2 lines should be equivalent, but not. Or, if you say this is good, what parameters should go.set_parent be called, which gives the same behavior as msg.post (url, “set_parent”)?
These are the same:
msg.post("go2", "set_parent", { keep_world_transform = 1 })
msg.post("go2", "set_parent") -- default for keep_world_transform is 1
go.set_parent("go2", nil, true)
And these are the same:
msg.post("go2", "set_parent", { keep_world_transform = 0 })
go.set_parent("go2", nil, false)
go.set_parent("go2", nil) -- default is false
You write the same in the bottom 2 lines as I do:
msg.post(“go2”, “set_parent”) – default for keep_world_transform is 1
go.set_parent(“go2”, nil, true)
However, in the enclosed example program, these 2 lines give different results, go.set_parent (“go2”, nil, true) does not keep the position. Please, check it!
Oh, yeah!!! You’re right… We’ll investigate. Thanks.
Thanks! Sorry for my English!
Created #4099