Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 bawenang · Oct 24, 2012 at 06:20 AM · animationrenderingculling

Animation not rendered when object is close to one another

Hi guys, first thing first. I have this code:

 using UnityEngine;
 using System.Collections;
 
 public class SpawnActor : MonoBehaviour {
     
     public GameObject actorPrefab;
     
     private float spawnTime = 0.5f; //0.5 secs to spawn each
     private float spawnCounter = 0.0f;
     private int actorCounter = 0;
     
     
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
         spawnCounter += Time.deltaTime;
         
         if (spawnCounter > spawnTime)
         {
             spawnCounter -= spawnTime;
             
             Spawn ();
         }
     }
     
     void Spawn()
     {
         GameObject actor = (GameObject) Instantiate(actorPrefab);
         
         actor.name = actor.name + "_" + (++actorCounter).ToString("D3");
         actor.transform.position = Vector3.zero;
         actor.transform.rotation = Quaternion.identity;
         
         actor.animation.Play("Take 001");
         
         StartCoroutine(DeletionCoroutine(actor, actor.animation["Take 001"].length));
     }
     
     IEnumerator DeletionCoroutine(GameObject actor, float time)
     {
         yield return new WaitForSeconds(time);
         
         Debug.Log ("Actor to be deleted: " + actor.name);
         Destroy(actor);
     }
 }

This is just a simple spawning script which will create a gameobject every 0.5 secs, play a pre-determined animation a-la cutscenes (just a simple walking forwards a few steps actually), and then deleted it at the end of the animation.

Now the problem is, every now and then, a few of the objects will be culled and not rendered at all (maybe because the time interval is too short and the objects are close to one another?). The reason I know that it is culled rather than destroyed was because I have this line in the Spawn() function:

actor.name = actor.name + "_" + (++actorCounter).ToString("D3");

And this line in the DeletionCoroutine() function:

Debug.Log ("Actor to be deleted: "+ actor.name);

And the order of the actor was actually correct, so I assume the order of the deletion itself must have been correct also.

Now the question, why did the object not rendered? How do I solve this? BTW, I've tried the "Always Rendered" in the animation's culling type to no avail.

Thanks in advance.

EDIT: I forgot some more info, if that will be useful. The GameObject doesn't have a collider at all. And actuallly I forgot to add one more line in the Spawn() function. It actually has this: actor.animation["Take 001"].speed = 2.0f;. Or in a way, the animation is played at twice the speed.

Comment
Add comment · Show 1
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
avatar image bawenang · Nov 22, 2012 at 06:22 AM 0
Share

No answer yet? Oh well, I just added some delays for the spawning for now so they won't get spawned as close to one another. I hope it solved the problem for the time being.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Balin Ebergy · Feb 03, 2013 at 03:47 AM

Actually it may not because of the spawning time yet the playing time. I encountered the same problem with 3.5.6f4 and tried your solution - not work :(

After some hard works I solved the problem by applying some random delay (about 0 to 0.1s) to the objects and it works fine now. I thought it may be some bugs in Unity. Hope it will be useful for others.

Comment
Add comment · Show 1 · 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
avatar image bawenang · Mar 04, 2013 at 04:46 AM 0
Share

Sorry, for the delay. I've been postponing the development of the game and busy with other stuffs. Thanks for the reply. $$anonymous$$aybe I'll try your solution when I'm working with it again. I'll accept your answer if I can try it myself. Again, thanks a lot.

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

10 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

Related Questions

Image effects do not work when rendering with multiple cameras 0 Answers

Can the Cull option in shader improve perfomances ? 2 Answers

[Solution in answers] Skinned Mesh Renderer only appears if it's visible in the Scene window 4 Answers

How to render a cinematic or a cutscene in Unity? 0 Answers

How can I solve animating objects rendering behind static? 0 Answers


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