- Home /
Is there a way to check how many objects are destroyed on the frame?
I want to find out when there are multiple objects destroyed in a frame or a certain amount of time, depending on that there will be more or less score, how can I accomplish this?
Answer by Sisso · Sep 16, 2014 at 12:20 PM
I don't think so. But even if unity3d have it, in the long run don't appear to be a good way to implement this feature.
There many ways to implement this, one Simple is to create a script that OnDestroy send a message to some Score Manager (search for singleton pattern). Give you a good flexibility, independence and centralized control.
how would I accomplish this if the objects both have the same script? and send the same message to the score script, how can I let the score script know that there are 2 sending the message? ins$$anonymous$$d of it executing the code I want it to 2 times, but ins$$anonymous$$d multiplying the code? (it gets sent on the same frame)
Each call of Send$$anonymous$$essage will invoke the listener method one time. And you can always send itslef as parameter. Simple do some tests with debug messages and do some tests until you understand how it works. Is really a nice tool.
Your answer
Follow this Question
Related Questions
Script Instantiates only one platform? 1 Answer
How to destroy in an amount of time 1 Answer
execution order of Destroy and Physisc.Raycast 1 Answer
How does Time.deltaTime provide smoother physics functions? (Frame rate question) 2 Answers
How to update new frame while another is computing? 0 Answers