x


change or replace objects

hello how can it be possible when the player clicks an object 1 , object 2 replaces to object 3

.. and is it possible when player clicks object 1 object 2 will be removed?

more ▼

asked Jul 17 '10 at 02:17 PM

Nicky gravatar image

Nicky
22 4 4 4

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

2 answers: sort voted first

just store the references of objects in each other and Destroy objects that you don't want and Instantiate others. something like this

var object2 : GameObject;
var object3 : GameObject;
function OnMouseDown ()
{
//if you want to replace you should Instantiate in object2's position
Instantiate(object3,object2.transform.position,object2.transform.rotation);
//remove object 2
Destroy(object2);
}
more ▼

answered Jul 17 '10 at 04:16 PM

Ashkan_gc gravatar image

Ashkan_gc
9.1k 33 56 117

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

i came across this same problem as well but the problem with this solution is that at a short instant of time both objects share the same space making there colliers collide launching the newly instantiated object into oblivion. the only way i could find to get around this is by making the script instantiate an empty game object that deletes object2 and then instantiate object 3 then deleting itself.

more ▼

answered Feb 06 '11 at 11:19 PM

creative72 gravatar image

creative72
143 5 5 14

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

x1090
x379

asked: Jul 17 '10 at 02:17 PM

Seen: 2444 times

Last Updated: Jul 17 '10 at 02:17 PM