|
Hi everyone, I am working on a tetris like game. So I have a class called OBlock. It has a 2x2 multidimensional array of prefabs called Block. OBlock doesn't inherit from MonoBehaviour. I use a timer in OBlock to move the blocks in the 2D array one step down. in OBlock in Block When I run this code I get the following error.
I get the same error even when I do this The weird thing is that I was able to change the blocks' location at the start of the code. in OBlock.cs in Block.cs and no error appeared. So I tried this but I got the same error pointing to line 40. Can someone help me with this? Sorry for the long question. I want to give you as much details as possible.
(comments are locked)
|
|
I'm pretty sure .Net Timers are executed in their own thread. In Unity it is not possible to manipulate the scene hierarchy (all objects instantiated on the current scene) from outside the main thread. But I don't understand the need of timers. Unity API already provide everything you need for timed behaviours. You may want to use the Time.deltaTime in an Update() of your script or a coroutine. With a coroutine: Inside Update method: I'm using a timer because I want the the blocks to move down every second. Not every frame. Is there is a way to do that without using a timer?
Feb 04 '12 at 09:35 PM
MarwanMR1
With a coroutine: Inside Update method:
Feb 04 '12 at 09:52 PM
Kryptos
Thanks, I'll try that
Feb 05 '12 at 06:47 AM
MarwanMR1
It worked perfectly. Thanks alot
Feb 05 '12 at 11:59 AM
MarwanMR1
(comments are locked)
|
