x


GUI script problem

whats wrong with my script ...i want the enemy to take 100 damage then the GUI pops up then when you press the button the enemy gets destroyed left with a dead replacement..like a ragdoll

http://pastebin.com/mCLLXX1c

more ▼

asked Jun 17 '11 at 10:59 AM

cocopuffs gravatar image

cocopuffs
1 2 3 4

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

2 answers: sort voted first

If this script is on the enemy, you are destroying the enemy before you are finishing your code. Once you destroy it, it can no longer execute the code. Also, you are calling function OnGUI, but OnGUI is always called anyway.

In the future, please try not to ask "whats wrong with my script" but instead, tell us what you intend to do(as you did) and tell is what it is actually doing.

Let me know if that worked for you.

more ▼

answered Jun 17 '11 at 11:32 AM

Anxowtf gravatar image

Anxowtf
1.6k 22 27 38

no the script is attached to the player.....

Jun 17 '11 at 11:34 AM cocopuffs

then you add the enemy from the hieriach to the
var enemy : GameObject;

Jun 17 '11 at 11:36 AM cocopuffs
(comments are locked)
10|3000 characters needed characters left

sorry forgot to mention this is a math game so when the cube/enemy takes 100 damage a GUI pops up with a multiple choice math question...and if you answer right the enemy gets destroyed and replaced with a dead replacement like a ragdoll:) ....and if you answer wrong nothing happens yet..everything works but i cant get the cube to show the question only when it takes 100 damadge:(

more ▼

answered Jun 17 '11 at 11:33 AM

cocopuffs gravatar image

cocopuffs
1 2 3 4

(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:

x3814
x3420
x254
x167

asked: Jun 17 '11 at 10:59 AM

Seen: 481 times

Last Updated: Jun 17 '11 at 11:36 AM