- Home /
Transform var between scripts
OK. I hope it's a simple sollution that I'm just missing as a newbie.
I've got two scripts on one GameObject. One is in JavaScript, second in C#. JavaSC instantiates anothe gameobject - C# is supposed to "catch" it's Transform as a variable.
I need to transfer a Transform variable from JavaSC to C# script. I'm mainly working on JavaSC and got no idea about C# (yet).
How would a basic code for both scripts look for that? On the JavaSC side it'll be a simple public var - but on the C#?
Answer by YoungDeveloper · Jun 18, 2014 at 06:47 PM
Don't mix different programming languages, it's not a good practice.
Use GetComponent to access other scripts, i wrote very detailed explanation here:
http://answers.unity3d.com/questions/550578/cant-understand-getcomponent-c.html
http://answers.unity3d.com/questions/597617/how-do-i-addsubtract-variables-between-two-differe.html
Ok, I feel so bloody stupid right now. :P Ins$$anonymous$$d of instantiating stuff in one script and sending var info to other script, I just made an instantiate command on C# script, accessing "clone's" Transform directly in the same coding language.
Sorry for trouble and thanks again. :D
Answer by tanoshimi · Jun 18, 2014 at 06:46 PM
You do know that Unity has documentation, right?
which is usually not that helpful because we beginners have a hard time knowing what to change in the example to make it work in our exact project.
Tanoshimi, Don't comment if you're deliberately trying to be rude.
Your answer
![](https://koobas.hobune.stream/wayback/20220613151847im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
More elegant use of struct and class 1 Answer
Help, How can I get variables? 1 Answer
Some Basic Conversions from JavaScript to C# 1 Answer
Convert from javascript to c# 2 Answers