Hey everyone,
i am a programmer with a year of experience in unity and coding on my back! Recently i decided to take on a project, Rpg to be more precise, and i had as a main goal to re-create or remaster(whatever word you prefer) a game that i devoted lots of hours. Now i have come to a point that i have attack animations inventory and everything that a RPG game need but i stuck while coding the instantiate system which will be responsible for instantiating items on the player’s model. But so far i have only been able to spawn them into the player with the wrong rotations. No matter what i do the rotation’s will be missplaced! I do not have any code for it(only saving the items rotation before instantiating). So can someone help me on this one?
Generally you address this by inserting extra gameobjects into the hierarchy such that every piece of equipment hangs properly on the player when its base transform is reset, ie., position 0,0,0, rotation 0,0,0 and scale 1,1,1.
Kurt’s answer was a good one. When you design your items, make sure you set there pivot at at spot that makes sense.
An example would be to have the handle of an item resting on the origin.
Now create an empty game object and parent it to the hand of your player, so that it rests slightly above the hand. Then, when instantiating set the parent of the item to this object and everything should be good.
you need to instanciate objects to correct object or the rotations will be modified at runtime.
import models from asset store with lot of good reviews and try to work on it you will know correct way.
put an empty game object onto the player and use it as an anchor for your item. make your item the rotation and scale you want it to be and set to position to 0,0,0. you should be able to instantiate it as a child of the empty game object and it will be the correct rotation.
Collin’s answer is correct. You need placeholders that are positioned at the correct point in the hand or wherever. You then only need to make sure that your items for example weapons are all positioned pointing in the same direction and with their grab point at the same 0,0,0 poisition. Anything that follows that placement rule can then be attached to the placeholder, zero’d, and will be as it should.
I recommend watching BergZerg’s Arcade RPG tutorials.