C
C#13mo ago
Temptica

Unity Setting Parent (XrOrigin)

So I have a player who needs to take a bus. But when the player steps on the bus, it just teleports to a very offset position. The bus has an animation, a bus object that is scaled which is just the visual model, a cube which detects if a person is trying to step on the bus, and offset which I'll explain later. The player has a cube in the camera offset which is the collision box (see screenshot 1) As code I have this on trigger Enter that checks if the bus is stopped and if the collider is a player. The collider is this cube so to get the Xr Origin I take transform.parent.parent. Then I get the offset object (it was a test solution, hence the bad tag and naming). This has a very big offset so when I attatch the player to it when you stepped on at the back, you end up at the exact same spot. This only works if you step exactly in the middle of the back door. If I use SetParent, no matter if I give true or false, or I set my parent this way, My player always ends up far away from the bus while still being attatched
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?