hi guys i m trying to make power up like in subway surfer or temple run MAGNET one.
when ever character picks up the magnet powerup i want my character to pull the coins near by him.
how can i achieve this one any help would be great.
The vector3 distance check if we a within a given range, if we are we use interpolation to move towards our player at a given speed (coinSpeed). Just make sure that the coin is faster than the player.
hi guys i did something like this when i gets magnet power up my coins collider get bigger in radius and when ever character enters the sphere collision it moves toward the character n gets destroy. do u guys think this will be expensive? tks
Physic engine works using trees, splitting the world into smaller chunk. So when you do any physic call, you’re not checking everything, but only stuff within specific tree nodes.
Also, I would advice using sqrMagnitude over Magnitude or Distance when doing comparison.
GameObject.FindGameObjectWithTag() is very slow, caching the object in a GameController singleton would be a much smarter/faster way to handle that. Also (distance1-distance2)…sqrMagnitude < distanceAway is faster than Vector3.Distance