Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 15521

How can I rename my creature's model's hierarchy without breaking animations?

$
0
0

I am a beginner at Unity in terms of skill so please explain as if you were talking to a child if you can!

PROBLEM

I would like to change these names here:

enter image description here

I would like to rename them for two reasons:

  1. so they are more intelligible

  2. because I am using many different assets from the store and each has a different hierarchy with different names and I want to standardize the names so that I can use the below code to determine which part of the creature's body was shot so that it works for every creature

     public    void            CreatureHit(string bodyPart, GunInfo usedWeapon, float intensity)                    // for guns {     usedWeapon.PlayHit(creatureSounds);     if (creatureInfo.healthPoints > 0)                                                                        // to prevent dead creatures from being shot     {         if ("Torso" == bodyPart || "LeftUpperArm" == bodyPart                                                // if the part that was hit was the arms or torso                 || "RightUpperArm" == bodyPart || "LeftLowerArm" == bodyPart                                // if the part that was hit was the arms or torso                 || "RightLowerArm" == bodyPart)         {             creatureInfo.healthPoints -= usedWeapon.damage * intensity;                                     // deal standard dmg             if (creatureInfo.healthPoints <= 0)                 creatureInfo.deathType = CreatureInfo.BODYSHOT;         }         else if ("Head" == bodyPart)                                                                        // if the part that was hit was the head         {             creatureInfo.healthPoints -= usedWeapon.damage * 10 * intensity;                                // deal 10x dmg             audioSource.PlayOneShot(creatureSounds.hitHead, 1);             if (creatureInfo.healthPoints <= 0)                 creatureInfo.deathType = CreatureInfo.HEADSHOT;         }         else if ("RightUpperLeg" == bodyPart || "LeftUpperLeg" == bodyPart             || "RightLowerLeg" == bodyPart || "LeftLowerLeg" == bodyPart)         {             creatureInfo.healthPoints -= usedWeapon.damage / 2 * intensity;                                    // deal half dmg             if (creatureInfo.healthPoints <= 0)                 creatureInfo.deathType = CreatureInfo.BODYSHOT;         }     } }   

WHAT I TRIED

I renamed them in the hierarchy but then the animations stopped working. I found an old thread from the Unity forum asking if this was possible in 2015 and the OP was told that it wasn't. There were some later technical replies and I felt overwhelmed so I thought I should just create my own thread.

NOTE: there are multiple dozens of characters each with 10+ animations so ideally I need a very efficient solution.


Viewing all articles
Browse latest Browse all 15521

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>