Hi All
I implemented a simple script to activate a coin object (from an object pool) , and add force to the coin so that it moves to the right. The idea is, when I kill an enemy object, a coin will be "spawned" and move to the right of the enemy object. There is also a drag force on the coin object so that the coin will eventually stop moving.
The problem is, it works most of the time. The enemy killed, coin spawned, moved and stopped. However, occasionally, the coin would not move at all!!! the coin just spawned and stayed where the enemy object was.
the code:
myCoins[i].rigidbody2D.AddForce(new Vector2(1.1f,0.0f) * _force);
I have been struggling with this for days and still cannot figure out the problem! any advice is much appreciated
↧