Answered

Renaming the weapon of a Humanoid

amirmahdijavidpour 4 years ago updated by Peter - Soxware Developer 4 years ago 3

Hello,So let me explain Im Creating  Humanoid Animations with guns for my game 
My guns are rigged as generic gameobjects and they are parent of the RHand

When I Export the .anim files Everything works fine,

but when I change the name of the weapons the animations doesnt work anymore

I want to have different prefabs such as M4A1-HoloGraphic , M4A1-IronSight etc for a single weapon

is there any way that I can have different names and still have my animations working without making animations for every single prefab ? since i have rigged guns thought its ok to change name of the gameobjects

UMotion Version:
1.22p11
Unity Version:
2019.4.6

Answer

Answer
Answered

Hi,
thank you very much for your support request.

Animations (*.anim files) are binding the animation curves to bones/transforms via "transform paths". For your gun the transform path might look something like this: Hips/Spine1/.../RHand/M4A1.

So you would have to manually adjust the animation and change the transform paths. But I would probably use a different/easier approach: Make the holo-sight and the iron sight separate objects and just enable them to your needs (but use only one "base" m4 model). You can separate meshes from models using a 3D modeling application of your choice (Blender, Maya LT,...).

Please let me know in case you have any follow-up questions.

Best regards,

Peter

Answer
Answered

Hi,
thank you very much for your support request.

Animations (*.anim files) are binding the animation curves to bones/transforms via "transform paths". For your gun the transform path might look something like this: Hips/Spine1/.../RHand/M4A1.

So you would have to manually adjust the animation and change the transform paths. But I would probably use a different/easier approach: Make the holo-sight and the iron sight separate objects and just enable them to your needs (but use only one "base" m4 model). You can separate meshes from models using a 3D modeling application of your choice (Blender, Maya LT,...).

Please let me know in case you have any follow-up questions.

Best regards,

Peter

Hi thank you for your response

Im already doing this I have separate models like holoSight underBarrels ...... and i Attach them to my M4 model and enbale disable them when i want to

but you see the problem is how should I know which soldier have the m4 with acog or m4 with underbarell for example when they die which gun with which attachments should be drop for Player

I just wanna change the name of the M4 model in the unity and have it Still working so I can make prefabs for using in my whole game

and im controling  the Guns with their Rigs and not their main model obejct in animations 

Sorry if its a bit confusing I wish I could explain better 

Your script could either check what configuration of your M4 is active (by checking the holoSight.gameObject.isActiveSelf property) or (probably cleaner) you use a member variable (e.g. an enum) that remembers the configuration of the M4. Changing the name sounds like a "hacky" solution to me (it also has some performance penalties as creating strings creates memory garbage, and comparing strings is a rather slow operation). And it breaks any animations addressing the M4.

If you want to keep track of the M4 configuration even when the weapon is dropped by the character, your weapon script (that is assigned to the M4) should be the script that remembers the configuration.


The only other options you have is to create one animation per M4 name (you would need to rename the transform paths as mentioned in my first post) or you create an empty GameObject as parent of the M4 that always has the same name. In your animation you animate that empty parent GameObject instead of the M4.


Best regards,

Peter