x


What's wrong with my scale script?

So what's wrong with it? The ground will instantiate, but not scale.

var ground : GameObject;
var roadLength : int = 15;
var numberOfRoads : int = 10;


function Start (){

Instantiate (ground, Vector3(-10,0,-10), transform.rotation);
transform.localScale.x = numberOfRoads * (roadLength+35)+200;
transform.localScale.y = 100;

}
more ▼

asked Apr 21, 2011 at 08:45 PM

Muzz 1 gravatar image

Muzz 1
638 151 113 129

You've both said practically the same thing! I can't mark them both right, so I'll just vote both up.

Apr 21, 2011 at 08:56 PM Muzz 1
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

You are scaling 'this' object, not the one you instantiated. Try

var newObj = Instantiate (ground, Vector3(-10,0,-10), transform.rotation);
newObj.transform.localScale.x = numberOfRoads * (roadLength+35)+200;
newObj.transform.localScale.y = 100;
more ▼

answered Apr 21, 2011 at 08:53 PM

DaveA gravatar image

DaveA
33.4k 417 336 443

You won the race...thanks for the quick reply.

Apr 21, 2011 at 08:57 PM Muzz 1
(comments are locked)
10|3000 characters needed characters left

Your code should be something like:

var clone : GameObject;
clone = Instantiate (ground, Vector3(-10,0,-10), transform.rotation);
clone.transform.localScale.x = numberOfRoads * (roadLength+35)+200;
clone.transform.localScale.y = 100;
more ▼

answered Apr 21, 2011 at 08:53 PM

Mortennobel gravatar image

Mortennobel
1.9k 24 25 50

Beat ya by 14 seconds ;)

Apr 21, 2011 at 08:54 PM DaveA

Yep :-) Congrats :-)

Apr 21, 2011 at 08:55 PM Mortennobel
(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:

x9063
x6166
x671

asked: Apr 21, 2011 at 08:45 PM

Seen: 2801 times

Last Updated: Apr 21, 2011 at 08:45 PM