Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Yet another animation/Skeleton question.

Discussion in 'Scripting' started by spil778, Jul 13, 2016.

  1. spil778

    spil778

    Joined:
    Mar 31, 2013
    Posts:
    57
    Hey guys.
    I seen tons of these kind of question however I cannot see any that clears out the problem I am having...
    Well I am using an converter from PMD to FBX and I seem to have some problems here...

    So lets get on with it:

    Thats the structure of the player. Thats how its imported in

    Now say we want the pants:

    Which for starters not always have the same name nor same number.
    I tried to merge then with different scripts I found around.
    However most of the time it seems to be based off name and since thats not the same, Theres a problem.

    I was wondering since it generates an Avatar is it possible I can take whatever is stored in the HIP and map that to the players Avatar?...

    This is a new area for me so I apolozie if this have been posted but with my vocalbulary I could not find anything.

    EDIT: ups the problem lies in that the animation does not follow
     
  2. spil778

    spil778

    Joined:
    Mar 31, 2013
    Posts:
    57
    Nobody?
     
  3. SkaredCreations

    SkaredCreations

    Joined:
    Sep 29, 2010
    Posts:
    296
  4. spil778

    spil778

    Joined:
    Mar 31, 2013
    Posts:
    57
    Welp, with this code:
    Code (CSharp):
    1. using UnityEngine;
    2. using System;
    3. using System.Linq;
    4. using System.Collections;
    5. using System.Collections.Generic;
    6.  
    7. public class EquipManger : MonoBehaviour {
    8.     //public GameObject TargetWithAvatar;
    9.     public Animator Ref;
    10.     public Animator Target;
    11.     public Avatar ava;
    12.  
    13.     public Transform temp;
    14.     //HumanBone, Name
    15.  
    16.     public struct BoneRef{
    17.         public BoneRef(HumanBodyBones _bone, string _name, Transform _trans){
    18.             bone = _bone;
    19.             name = _name;
    20.             trans = _trans;
    21.         }
    22.  
    23.         HumanBodyBones bone;
    24.         string name;
    25.         Transform trans;
    26.  
    27.         public HumanBodyBones GetBone(){
    28.             return bone;
    29.         }
    30.  
    31.         public Transform getTrans(){
    32.             return trans;
    33.         }
    34.  
    35.         public string getName(){
    36.             return name;
    37.         }
    38.     }
    39.  
    40.     void Start(){
    41.        
    42.         //Ref = gameObject.GetComponentInChildren<Animator>();
    43.         //Target = TargetWithAvatar.GetComponentInChildren<Animator> ();
    44.         List<BoneRef> exisitingBones = new List<BoneRef> ();
    45.  
    46.         HumanBodyBones tempEnum;
    47.         Debug.Log (Enum.GetValues (typeof(HumanBodyBones)).Length.ToString());
    48.         for (int i = 0; i < Enum.GetValues(typeof(HumanBodyBones)).Length; i++) {
    49.            
    50.             tempEnum = (HumanBodyBones)i;
    51.  
    52.  
    53.             if (Target.GetBoneTransform(tempEnum) != null) {
    54.                 Debug.Log (tempEnum.ToString());
    55.                 Debug.Log (Target.GetBoneTransform(tempEnum).name);
    56.                 Debug.Log("-----------------------------------------------------");
    57.                 exisitingBones.Add (new BoneRef (tempEnum, Target.GetBoneTransform (tempEnum).name, Target.GetBoneTransform (tempEnum)));
    58.             }
    59.             Debug.Log (Target.GetBoneTransform(tempEnum));
    60.         }
    61.  
    62.         Debug.Log (exisitingBones.Count);
    63.         for (int i = 0; i < exisitingBones.Count; i++) {
    64.             Debug.Log (exisitingBones.ElementAt(i).getName());
    65.         }
    66.     }
    67. }
    68.  
    I get null on:
    Code (CSharp):
    1. Debug.Log (Target.GetBoneTransform(tempEnum));
    Seems like it doesn't generate an avatar. Any suggestion what to do?
     
  5. spil778

    spil778

    Joined:
    Mar 31, 2013
    Posts:
    57
  6. spil778

    spil778

    Joined:
    Mar 31, 2013
    Posts:
    57
    Anyone?