- Home /
trail renderer disapear, strange behavior
Am trying to make 2 falling stars.
When player hit a trigger area, the star move with some speed (- some aceleration). the stars are 2 planes with materials (particles/alpha blended multiply) and trail renderer
here is the code
using UnityEngine;
using System.Collections;
public class control_cometa : MonoBehaviour {
public GameObject cometa_estela;
public bool movimiento=false;
/*public float p_mov_x=1;
public float p_mov_y=1;*/
public float velocidad=10f;
public float desaceleracion=2f;
// Use this for initialization
void Start () {
cometa_estela.gameObject.active = false;
}
// Update is called once per frame
void Update () {
if(movimiento){
cometa_estela.transform.Translate(Vector3.left * velocidad);
velocidad -= desaceleracion;
if(velocidad<0){
movimiento=false;
Destroy (cometa_estela);
Destroy (gameObject);
}
}
}
void OnTriggerEnter( Collider colison ){
if( colison.gameObject.tag == "jugador" ){
if(!movimiento){
//Debug.Log("mov");
cometa_estela.gameObject.active = true;
//StartCoroutine(mover_cometa());
movimiento=true;
}
}
}
}
The result is this: ![alt text][1] [1]: /storage/temp/4381-asdf.jpg
please show me how to see my star :D
Answer by GeorgeRigato · Oct 24, 2012 at 06:20 AM
My guess here you use the `gameObject.active = false` to hide the object. Try using this:
cometa_estrela.renderer.active = false;
I am thinking that when you deactivate the entire game object, it stops responding collisions, and can't reactivate itself.
Maybe I am wrong, but that is what crossed my mind.
Otherwise, your collision could be messed up, missing rigidbody or the trigger box checked.
Good luck!
no no. if you saw the picture (attached file "asdf.jpg"), the trail is there but i cant see it with the main camera.
theres no rigidbody. the gameobject is just a cube without render, only collision box.
the camera cant reach it ? why show me only 1. Its the same script !
Your answer
Follow this Question
Related Questions
[Error] Error While Importing Packages 0 Answers
Modifying material modifies the actual .mat file! 0 Answers
Trail rendering 1 Answer
Ugly Shadows 2 Answers
[WITH IMAGES] Portal teleporter works, but only when walking through very slowly 1 Answer