Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Error: not a member of 'UnityEngine.GameObject[]'.

$
0
0
Hi the code below is giving me this error and I can't seem to figure out why I think its from assigning something with the array wrong but can' t figure why it gives me the error below? **Code:** #pragma strict var birdAnimator : Animator; var electricityParticleGameObject : GameObject; var scoreValue = 1; var script : Move_Left_Script; var scoreControlScript : Score_Control_Script; var coinBurstParticles : GameObject; var magnetGlowParticles : GameObject; var coins : GameObject[]; var trigger = false; var speed : float; function Start () { for (var i : int = 0; i < 7; i++) { coins = GameObject.FindGameObjectsWithTag("Coin"); } } function OnTriggerEnter2D(other : Collider2D) { if (other.tag == "EvilCloud") { // script.pauseEvilCloudTrigger = true; // Activate bird shocking animation birdAnimator.enabled = true; // Trigger for update function to make sure bird hit cloud before it runs electricity shocking effect electricityParticleGameObject.active = true; // Destroy Bounce Controller Script on Bird so it disables bouncing from the players input Destroy(GetComponent(Bounce_Controller_Script)); // Destroy Rigidbody so Bird doesn't fall right away ShockPauseFall(); // Set High Score scoreControlScript.SetHighScore(); Debug.Log("Player hit evil cloud. End Game!"); } if (other.tag == "Coin") { // Spawns coin burst particles at the location of where the coin was hit and then destroys the particle system after 2 seconds var coinBurstClone : GameObject = Instantiate(coinBurstParticles, other.transform.position, Quaternion.identity); Destroy(coinBurstClone, 2); // Add a point to the current score when coin is hit and also update high score if its lower then current score // then disable renderer and collider2D and it gets renabled when it repostions in Coin Spawner Script Score_Control_Script.currentScore += scoreValue; other.gameObject.renderer.enabled = false; other.gameObject.collider2D.enabled = false; } if (other.tag == "Magnet") { magnetGlowParticles.active = true; other.gameObject.renderer.enabled = false; other.gameObject.collider2D.enabled = false; trigger = true; Debug.Log("Magnet hit bring that ish!"); } } function Update () { var step = speed * Time.deltaTime; if (trigger == true) { coins.transform.position = Vector3.MoveTowards(coins.transform.position, gameObject.transform.position, step); } } function ShockPauseFall () { // Destroys rigidbody2D component so bird pauses then waits 2 seconds then adds a rigidbody2d and sets its gravity to 3 so it falls fast Destroy(GetComponent(Rigidbody2D)); } **Error:** Assets/Scripts/Gameplay Functionality Script.js(75,23): BCE0019: 'transform' is not a member of 'UnityEngine.GameObject[]'. Assets/Scripts/Gameplay Functionality Script.js(75,70): BCE0019: 'transform' is not a member of 'UnityEngine.GameObject[]'.

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>