Dynamically displaying 2D textures above 3D objects

Hello. I have been working with that few hours during 2 days and I can’t get what I wanted. And what I wanted? Something like gif above object (3 textures with phone and growing signal). I need visual effect of calling for reinforcement when enemy looks at player. It’s my visualization:

void Preparing(){
     radioTexture1.enabled = false;
     radioTexture2.enabled = false;
     radioTexture3.enabled = false;
   }
   IEnumerator Calling(){
     informing = false;
     for (int i=0; i<3; ++i) {
       Debug.Log("I'm working! iteracja " + i);
       radioTexture3.enabled = false;
       radioTexture1.enabled = true;
      
       yield return new WaitForSeconds (0.5f);
       radioTexture1.enabled = false;
       radioTexture2.enabled = true;
      
       yield return new WaitForSeconds (0.5f);
       radioTexture2.enabled = false;
       radioTexture3.enabled = true;
       yield return new WaitForSeconds (0.5f);
       radioTexture3.enabled = false;
      
     }
   }

radioTextures 1-3 are GUITexture empty objects with simple texture (childs of my enemy, local position (0,2,0). Any suggestions? I’m going mad, it looks so simple ;_;

I was trying

transform.FindChild("RadarSignalTexture1").position = Camera.main.WorldToViewportPoint(transform.position + 2*Vector3.up);

and it didn’t worked. When I created separate script and using similiar construction in child, it works (but texture is flying in each direction when I’m a bit far from enemy) and I can’t have 3 scripts in this situation and enabling and disabling each other after 0.5s. It’s a bit stupid… Please help :slight_smile:

1 Answer

1

Hi, using sprites instead of GUITexture might be a better solution. Did you check Unity’s team free project/tutorial to see how they do similar things. Example: Unity Asset Store - The Best Assets for Game Making

I saw them using sprites in 2D. It is possible to render sprites by SpriteRenderer, animate them (bool star as flag to start animation, then time and next frame of animation; everything looped for few cycles) in 3D, over the head of object? I realy wanted effect like this: http://img2.wikia.nocookie.net/__cb20100328111233/prototype/images/c/cd/Prototype_Past_Present_Radio-1-.png but I can't even draw picture over head without using OnGUI :/ Anyone can help me and show path to good solution?