0

Why does'nt my script work in unity? Trying to spawn on same location textureOrg.transform.position=Oplayer.transform.position;

24th May 2017, 8:17 PM
DoubleVermine
DoubleVermine - avatar
8 odpowiedzi
+ 2
Can I see the entire script somehow? Maybe via picture or copy paste all the code onto here? (Assuming my previous post didn't solve the problem) Just make sure some object has the script attached to it.
24th May 2017, 9:09 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
Looks fine to me. What is the error or warning message you are receiving?
24th May 2017, 8:56 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
The scripts only run automatically if it is attached to an object (as its component). The method: void Start() Will automatically be called once when loading. void Update() Will automatically be called every frame.
24th May 2017, 9:01 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
Then you have to call it somehow. Start() and Update() are similar to the 'main' method you see in code playground. Creating a method on your own won't be automatically called. void Start(){ myMethodName(); // go to method } void myMethodName(){ x.transform.position = ....; }
24th May 2017, 9:05 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
^ Good tip lol. I spent over an hour trying to make my high Score list work going crazy. After all that time I realized I never attached the script to an object in my scene
24th May 2017, 11:14 PM
LordHill
LordHill - avatar
0
the thing is my player object wont spawn on or even near the other. I also have trouble with other codes not working. I am starting to think that my unity has problems loading the scripts or something.
24th May 2017, 8:59 PM
DoubleVermine
DoubleVermine - avatar
0
I used this script inside a void I created but it still wont load
24th May 2017, 9:03 PM
DoubleVermine
DoubleVermine - avatar
0
Btw i did not get any errors either
24th May 2017, 9:06 PM
DoubleVermine
DoubleVermine - avatar