Hey all,
Simple stuff here… I am attempting to modify a C# script, but don’t have much experience with the language. If I want to transform a parent object (or any other object for that matter) what would be the appropriate syntax? The JavaScript find by name method doesn’t seem to translate. Also on that note, what type of variable would I store the other object’s transform in if I wanted to assign it during initialization?
Thanks for any help.
Matt
Heya Matt, I had similar questions when I first started out, folks around here are great at helping, and there are tons of examples in the docs and in the showcase area people have posted downloadable games to boot. You might want to grab ahold of the FPS or any other resource projects and see how they are constructed, that will be better then try to explain a little at a time.
C# is strictly object oriented.
The functions always can be found as static function on the related class.
for example GameObject.Find and the like.
The script reference that you can find in the help menu when having unity running (or on the page in the documentation) shows the classes where you can find them.
private GameObject cubeObject; //set up the field
cubeObject = (GameObject) GameObject.Find("Cube"); //find the object
for the component (let’s say collider)
private Collider cubeCollider;
cubeCollider = (Collider) cubeObject.GetComponent(typeof(Collider));