- Home /
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;
}
You've both said practically the same thing! I can't mark them both right, so I'll just vote both up.
Answer by DaveA · Apr 21, 2011 at 08:53 PM
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;
Answer by Mortennobel · Apr 21, 2011 at 08:53 PM
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;
Your answer
![](https://koobas.hobune.stream/wayback/20220613124332im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
Scripting Meshes Subdivision(Javascript) 0 Answers
How to lerp an object's scale? 2 Answers
Is there a way to scale everything in my game (GUI, text size, etc.) on Android in Javascript? 2 Answers