简体   繁体   中英

How to attach gameobject without inheriting scale in Unity

I'm trying to make grapple hook mechanic for my game and I have problem with attaching hook to the rope. Rope is changing its length during game by scaling up and down. Because of that when I attach the hook to the rope by hinge joint it messes up after changing the scale of the rope. Is there any other way to do it?

Create an empty GameObject and add both the rope, joint and hook as child objects to it (ie all three should be siblings). This way, whichever part you scale won't affect the rest. To scale the whole thing, you have to scale the parent GO.

EDIT (for comment)
Do NOT scale the parent GameObject, but the rope only, so the hook's dimensions won't change.
For the other issue, the most simple (as of coding) solution I can think of is, to add two extra (empty) GOs: one as the parent of the rope, and place it to the end of it where the hook belongs to. The other as the parent of the hook, place it to the end of it (to the part which should attach to the rope) and after rope resize/scale, move the two GOs on top of each other

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM