Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Dan-Dylan · May 27, 2019 at 05:59 AM · animatorskinnedmeshrendererwarp

Can't turn material of SkinMeshRenderer list back to normal after animation.

Hello everyone,

I've having trouble figuring out where is my mistake in my code. I've been trying to do something similar to the warp in this video : https://www.youtube.com/watch?v=QAFL1NXnqog

The main difference being that my playerCharacter is warped to the position of the last bullet it fired using DOTween's DOMove method.

But I can't turn my skinnedmesh list material back to normal after my warp is done. Moreover, it seems that my animator component is somehow disabled during the cooldown of my warp ability.

I've trying moving the "skinnedmeshrenderer list" here and there but it either changes nothing or doesn't change the material to the glow one when warping.

Here's the code I'm working on :

//This is the part in the Update function.

     //Blinking
     if (Input.GetKeyDown(KeyCode.Space))
     {
         if (!warpOnCD && nbBullets.Count > 0)
             Blink();
     }


//And here are my methods

public void Blink()

 {
     int last;
     last = nbBullets.Count - 1;
     GameObject lastBullet = nbBullets[last];


     GameObject clone = Instantiate(gameObject, transform.position, transform.rotation);
     Destroy(clone.GetComponent<Animator>());
     Destroy(clone.GetComponent<Player>());
     Destroy(clone.GetComponent<Rigidbody>());
     Destroy(clone.GetComponent<CapsuleCollider>());


     SkinnedMeshRenderer[] skinMeshList = GetComponentsInChildren<SkinnedMeshRenderer>();
     foreach (SkinnedMeshRenderer smr in skinMeshList)
     {
         Debug.Log("GHOST");
         smr.material = glowMaterial;
     }


     transform.DOMove(lastBullet.transform.position - new Vector3(0, 1.5f, 0), warpDuration);
     Destroy(lastBullet);
     nbBullets.Clear();


   
     StartCoroutine("WarpCD");
     }

 IEnumerator WarpCD()
 {

     warpOnCD = true;
     animator.SetBool("Warping", true);
     Debug.Log("Warp on CD...");
     yield return new WaitForSeconds(5);

     warpOnCD = false;
     animator.SetBool("Warping", false);

     SkinnedMeshRenderer[] skinMeshList2 = GetComponentsInChildren<SkinnedMeshRenderer>();
     foreach (SkinnedMeshRenderer smr2 in skinMeshList2)
     {
         Debug.Log("IDLE");
         smr2.material = idleMaterial;
     }

 }



What is happening with this code :

  • My character creates a clone with "IDLE" material

  • Jumps to last position with "GLOW Material" on.

  • Stays on "GLOW Material" during the cooldown + animator is disabled.

  • Goes back to "IDLE" material and animator enabled at the end of the cooldown.

  • List item

I'd be glad to have some help, knowledge and tips on how to do what I'm trying to do.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Meishin · May 27, 2019 at 06:46 AM

Hello @Dan-Dylan, :

  • regarding animations you are setting "Warping" to True for 5 seconds so if you want the animation to last only for the animation time, be sure to have a transition from your warping animation to idle/some default state with no conditions set but "has exit time"=true.

  • for the SkinMeshRenderer, depending how you defined your new meshes, you might want to instantiate & add bones fitting, for ex

Option 0 : Change material only (which is what you seem to seek) Be careful here if your meshes has several materials you need to address it 1 by 1 Refer to : https://answers.unity.com/questions/175370/renderermaterials-not-working.html

Option 1 : change mesh only

 Mesh newMesh= Instantiate(inNewMesh) as Mesh;
 GetComponent<SkinnedMeshRenderer>().sharedMesh = newMesh;

Option 2 : Insert the corresponding mesh & fit bones

 if (newItem.mesh != null) { 
             SkinnedMeshRenderer newMesh = Instantiate<SkinnedMeshRenderer>(newItem.mesh);
             newMesh.transform.parent = targetMesh.transform;
             newMesh.bones = targetMesh.bones;
             newMesh.rootBone = targetMesh.rootBone;
             
 // Delete
             Destroy(newMesh.gameObject);
         }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

129 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple skinned mesh characters. 2 Answers

Either assign an existing skinnedmeshrenderer to another compatible rig, or controlling 2 instances of the same rig with 1 animator 0 Answers

Skinned Mesh Renderer not instancing in Unity 4 0 Answers

Runtime generated skinnedmesh does not animated until re-activating object or toggling Apply Root Motion 0 Answers

Animate multiple Humanoid Meshes with 1 Animator 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges