What is wrong with this, please? - cant spot my mistake..

function Update ()

{



    transform.Find("object").GetComponent(Object_rotate).turnSpeed = 100;

    

}

This is calling my GameObject, called “object”.

Hierarchy like this,

 - Slider - script one.

 - Object_slide
        - object - Object_rotate.js

And it is trying to call,

var turnSpeed = 0;

function Update () {

sPin = Time.deltaTime * turnSpeed;

transform.Rotate(Vector3.up * sPin);

}

2 Answers

2

try using GameObject.Find()

Ah worked, brilliant. Thanks! =D

And whats the problem with this? Doesnt it work? any errors?

Well first you shouldnt call your objects, objects.. this may confuse the system.

Second: you should save your result in a variable and then access to it

Woops, yeah i should have mentioned. It was a Null issue. And yeah, 'object' is just for the sake of these test scripts, but it was one of the first things that i checked. And the results need to be realtime, because it will be for control from a slider, was just testing it with a set figure because i wanted to make sure it worked first. Thanks for your help though, much appreciated. =)