I am trying to help you by giving you that link. If I just give you the code it wont help you much. Same reason teachers back in school made you do homework you were more likely to remember the answer then if they were to just give you it.
The series of tutorials on you tube will cover this topic your wondering plus many more. It will help get you off the ground and move you in the right direction. Another very helpful link you could check out is the scripting reference documentation.
Or even a quick search on the forums will bring up quite a bit of information on this subject.
You can’t want the answer very badly. If you had followed the advice given, instead of arguing over whether you should have the answer handed to you or not, you’d have it by now.
Ok, but it’s bad manners to post your question in someone else’s thread.
There isn’t one. Unity is based on a component model, not procedural. If you want to deal with actions which happen as your scene/level begins, then you need to write a behaviour, apply it to your object and then write an Awake() or Start() method in the behaviour. Check the documentation for a more detailed explanation on exactly when Awake() and Start() methods are called.
it would be nice if you can give me a link on how to create behaviors.
i have a hard time understanding the tutorial. i think it is the “organization” of the tutorials about scripting … i mean they are all useful, but where do i start?
on my case, i think i should start on behaviors … and then worry about putting those components later …
You declare it like so, making it an exposed variable.
var importantFloat : float
outside of any function. If your script is called Script1, and if you’re calling it from a script attached the same Game Object, you can just do
GetComponent(Script1).importantFloat;
This works for functions as well…like so…
GetComponent(Script1).SomeFunction(someArgument);
And come on guys, maybe a bit less harsh? I know you’re trying to help, but he probably is working on a project and might not want to go through 27 video tutorials. Sooner or later he’ll likely hit a large enough wall that will require him to do more tutorials, but this isn’t it.
When you dont have anything to do there is lots of time to look at the doc’s and video’s, but when your working on five projects, work two jobs have a cat dog and a fish and five kids to take care of and not any free time then this is where you get help from people willing to help and not turn you away :shock: