x


transform code!

Is there a code in javascript or any other programing launguage in unity to transform one object into another for example

if my person (object 1) it within a distance of (lets say object 2) and you hit the button e you transform into object 2 destroying the original object of object 2(the one you were next to)

I would like the script so i could change my person into a car (therefor i would just have the car as a fps controler and you could drive around)

thx i know this is complicated but try and make sense of it

more ▼

asked Feb 13 '11 at 05:37 AM

seatthief gravatar image

seatthief
63 6 7 14

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

1 answer: sort voted first

This is how you do it in javascript-

var obj1 : Transform; //this is you
var obj2 : Transform; // this is object2
var transformDist = 30;// this is the distance

function Update(){

if((distance >= Vector3.Distance(obj2.position, transform.position)) && (GetButtonDown("e")))
     transform();
}

function transform(){

Destroy(gameObject); //destroys your player
var replace = Instantiate(obj2, transform.position, transform.rotation); //this instantiates object 2 
}

//drag your player on the obj 1 slot and the car to obj2 slot 
//P.S. I haven't tested this script
more ▼

answered Mar 01 '11 at 06:23 PM

networkZombie gravatar image

networkZombie
244 9 11 20

THX Alot this realy helped

Mar 02 '11 at 05:39 AM seatthief
(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:

x3444
x1171
x531
x416

asked: Feb 13 '11 at 05:37 AM

Seen: 681 times

Last Updated: Feb 13 '11 at 05:37 AM