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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Incorrect bones position.

Discussion in 'Scripting' started by rugal77, Dec 15, 2018.

  1. rugal77

    rugal77

    Joined:
    Aug 9, 2017
    Posts:
    44
    I created a Mesh during Runtime via C#.
    However, I position the bones in their positions, but it is always in the center of the object.

    For example, the bone of the hand is in the center instead of being in the hand.

    Code (CSharp):
    1.  P_Bone[i].localPosition = new Vector3(x, y, z);
    "L UpperArm" is not in the position it should be
     
  2. rugal77

    rugal77

    Joined:
    Aug 9, 2017
    Posts:
    44
  3. rugal77

    rugal77

    Joined:
    Aug 9, 2017
    Posts:
    44
  4. rugal77

    rugal77

    Joined:
    Aug 9, 2017
    Posts:
    44
  5. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,900
    Maybe you need to make you point a little bit more clear? I (for one) don't really understand what you're doing, so I have no idea how I would be able to help you. Do you really create your mesh from code or just instantiate? Do you place the bones? Then what's the problem? If not, then how do you instantiate? Are the bones at correct positions when you instantiate normally by hand and animate it?
     
  6. rugal77

    rugal77

    Joined:
    Aug 9, 2017
    Posts:
    44
    I create the mesh during C #, and instantiate the bones.
    the problem is that they are not in the correct position, they are starting from the center of the object (0,0,0).
     
  7. rugal77

    rugal77

    Joined:
    Aug 9, 2017
    Posts:
    44
  8. rugal77

    rugal77

    Joined:
    Aug 9, 2017
    Posts:
    44
    Dump again :c
     
  9. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,333
    It's still not clear what the problem is. Since you are instantiating the bones yourself, why can't you just put them in whatever position that you want?
     
  10. rugal77

    rugal77

    Joined:
    Aug 9, 2017
    Posts:
    44
    Because it's a binary file, I'm reading the floats from the position of the bones.

    More for some reason, it is not in the correct position.
     
  11. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    328
    are you sure the values you're reading are correct?
    you're setting localPosition, are you sure the bones are correctly placed in the hierarchy?
     
  12. rugal77

    rugal77

    Joined:
    Aug 9, 2017
    Posts:
    44
    Yes. I'm using localposition.