- Home /
mesh? syntax question.
Woe...
var go : gameObject;
So that's problem 1 that I'm having. Problem 2 is figuring out how exactly to use MeshFilter.Mesh. Again, I'm borrowing code from a unityAnswers topic that gives me this:
go.GetComponent(MeshFilter).mesh = Instantiate(Resources.Load("Models/Turrets/machinegun"));
But when I run the function that the above line is found in (that is, the function that "upgrades" my object), I get a runtime error saying
"Object reference not set to an instance of an object
I'm hoping this means that I'm just not using the syntax properly. I have the mesh I'm trying to use in the Assets folder under Assets/Models/Turrets. Am I using the path syntax correctly, or is that wrong somehow?
I'm also open to other solutions, though I do need the mesh to be changed from within the script of its own object. Thanks for your time!
Answer by Loius · Nov 04, 2012 at 06:57 PM
Resources.Load (read the documentatiooooon) pulls from every folder named Resources located anywhere in your assets folder. The string up above would load the first asset found at:
Assets/any folder structure/Resources/Models/Turrets/machinegun
Your answer
Follow this Question
Related Questions
Changing Mesh and Mesh Collider of an Object 0 Answers
Player Ship Collisions 1 Answer
Change level after destroying all enemies? 1 Answer
change color object 2 Answers
Animated object changes position when animation is played. 1 Answer