x


Guitexture appear/disappear

Hello,

Frst of all sorry for my english,

I just want to know how i can appear or disappear a guitexture( it's 3 heart) when my character click on some objects

I have add a tag for each of my heart.

I have this line but i do not know how to use coe public GameObject coe = GameObject.FindWithTag("coe1");(it's for the first heart)

Thank you in advance.

more ▼

asked Apr 04 '12 at 05:53 PM

ar3l gravatar image

ar3l
0 1 1 1

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

So these are three GUITextures? Instead of using tags, I would use a GameObject array and then just disable elements from there. So, something like this:

var hearts : GameObject[];
private var clickCount : int = hearts.length;

function Update () {

if(Input.GetMouseButtonDown(0)){
    var ray : Ray = Camera.main.ViewportPointToRay (Vector3(0.5,0.5,0));   
    var hit : RaycastHit;    
       if(Physics.Raycast (ray, hit, 100)){
         if (hit.collider.tag == "click") {
          hearts[clickCount].enabled = false;
          clickCount--;
         }
       }
    }
}

Simply tag the object you want to click with the 'click' and add your GUITextures to the hearts array and you're good to go. :) I think it should work, but I created on air so I'm not so sure if it will ...

Hope that helps, Klep

more ▼

answered Apr 05 '12 at 04:16 AM

Kleptomaniac gravatar image

Kleptomaniac
2.5k 6 12 21

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2276
x494
x143
x111
x40

asked: Apr 04 '12 at 05:53 PM

Seen: 549 times

Last Updated: Apr 05 '12 at 04:16 AM