"set_parent" message is not fully compatible with go.set_parent (#4099)(SOLVED)

#1

Works well: msg.post(url, “set_parent”)
Works badly: go.set_parent(url, nil, true)

0 Likes

#2

What happens?

0 Likes

#3

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)

0 Likes

#4

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.

0 Likes

#5

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”)? :slight_smile:

0 Likes

#6

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
0 Likes

#7

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! :slight_smile:

2 Likes

#8

Oh, yeah!!! You’re right… We’ll investigate. Thanks.

1 Like

#9

Thanks! Sorry for my English!

1 Like

#10

Created #4099

2 Likes

#11

Solved in 1.2.156

1 Like