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
  4. Dismiss Notice

Rigged Armor and Mecanim

Discussion in 'Scripting' started by Danimita92, Jun 8, 2014.

  1. Danimita92

    Danimita92

    Joined:
    Jan 25, 2010
    Posts:
    31
    Hi everyone!
    I'm having a bit of trouble when adding armor to my player. I'm using the script masterprompt kindly shared here http://forum.unity3d.com/threads/stitch-multiple-body-parts-into-one-character.16485/

    Basically it creates a skinnedmeshrenderer that references my player's bones and makes it the player's child.
    And as an extra step, if for example the player picks up a helmet, I disable the player's "Head" skinnedmeshrenderer component.

    And it works wonderfully!
    Except when the player has to aim his weapon with mecanim's "SetLookAtPosition":

    animator.SetLookAtPosition(ikTargetPos);
    animator.SetLookAtWeight(1,1,1);

    Suddenly, this stops working properly. It starts to jitter, or it simply doesn't work.

    Also, the more skinnedmeshrenderers I disable, the worse it becomes.

    Anyone know how I can fix this?
     
  2. apomarinov1

    apomarinov1

    Joined:
    Oct 21, 2012
    Posts:
    66
    Hmmm could you try setting the script that creates the skinned meshrenderer to a higher/lower than default execution time at the script execution order window?
     
  3. Danimita92

    Danimita92

    Joined:
    Jan 25, 2010
    Posts:
    31
    Creating the armor and attacking it to the player is done in one of the player's functions, it executes once every time a new piece of armor is equipped. Maybe it has a slight framerate hiccup when it's generated, but after it's done, it shouldn't affect the Player's execution, and yet that's what it seems to do :/

    From what I've gathered, the more I disable the player's original skinnedmeshrenderers, and the more extra skinnedmeshrenderers I add, the worse the script executes the LookAtPosition(...)
     
  4. Danimita92

    Danimita92

    Joined:
    Jan 25, 2010
    Posts:
    31
    Solved! All I had to do was instead of disabling the old skinnedmeshes, I substituted their variables with those from the armor
     
    Last edited: Jun 9, 2014
  5. apomarinov1

    apomarinov1

    Joined:
    Oct 21, 2012
    Posts:
    66
    Interesting :) Glad you solved it.