I have about 30 weapons in my game. Most are axes and swords, the rest are spears. Is there a simple way to ensure that when I parent them to my model, that these weapons will align properly? I've been looking around on the internet as well as unity answers and still have yet to come up with a solution despite best efforts. If anyone could help I would be most grateful.
Answer by PrimeDerektive
Sep 09, 2011 at 08:35 PM
For each different weapon type (assuming different weapons require different alignments), parent an empty GameObject to the weapon hand and position/rotate that empty "mount point" into the perfect alignment for that weapon. Then when you Instantiate() your weapon objects, instantiate them at the position and rotation of the mount point, then parent them to the mount point.
I know all of that at this point, but it's still not working correctly for me. Is there any way that I can pre position a weapon prefab before it is parented so that I can make things easier?
basically the same idea but put the mount at the right position and rotation on each weapon rather than the character and make the prefab with the mount game object and the weapon already a child of that, then parent the weapons position to a point on the characters hand, bascially the smae concept but you can save the position with the prefab rather than the character. Scribe
I understand what you mean, however there is a difference seeing it in code and understanding the process. Perhaps I'm missing something but no matter how I try to code it doesn't really seem to work well.
In the editor, parent the weapon prefab to the "mount point" i mention in my answer, and set its both position and rotation to 0,0,0. Then rotate and position the mount point so the weapon is in the alignment that you want, then delete the prefab. That way, the mount point should be perfectly aligned, and you could instantiate your weapon prefabs at the position and rotation of the mount point and parent it to it.
finally got it working. thanks.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
4 People are following this question.
Instantiate New Gun
How do I parent a weapon to my character?
Is there a way to make a selected object a child of another object during the game?
Delay child objects rotation
Weapons for 3D character