can anyone tell what this script actually does
using UnityEngine;
using InfiniteRunner.InfiniteObjects;
namespace InfiniteRunner.Player
{
/*
* The coin magnet trigger will be active when the power up is active, and it increases the radius that collects coins
*/
public class CoinMagnetTrigger : MonoBehaviour
{
public bool coinMag= false;
public float Timer=0.0f;
CoinObject c = new CoinObject ();
GameObject p = GameObject.FindGameObjectWithTag ("Player");
GameObject[] currentCoins = GameObject.FindGameObjectsWithTag("Coin");
GameObject m = GameObject.FindGameObjectWithTag ("Magnett");
public void OnTriggerEnter(Collider other)
{
if (GetComponent<Collider>().gameObject.tag == "Magnett")
{
print ("inside game tag magnett");
coinMag = true;
if (coinMag == true) {
Timer += 1 * Time.deltaTime;
print ("inside coinmag == true");
if (Timer >= 10)
{
print ("inside timer");
coinMag = false;
Timer = 0;
}
}
}
foreach (GameObject Coin in currentCoins)
{
if (coinMag == true)
{
print ("inside last");
Coin.transform.Translate ((p.transform.position - Coin.transform.position).normalized * 4 * Time.deltaTime, Space.World);
c.CollectCoin ();
}
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
drag gameobject from ui scroll panel to 3d space 0 Answers
how to make a running player fly through the air at a particular distance from the ground 0 Answers
Trying find a solution to draw on seams with Ink Painter(Free Real-Time Texture Painting Asset) 0 Answers