I have a Model that I've made with 3ds max, and a little game, I want to create that object in the character's position when I press "T" for example, how would I do that?
Answer by whydoidoit
Sep 10, 2012 at 01:57 PM
You need to create a new game object and set its transform.position and .rotation to the character's position. Then you will need to add a MeshFilter component and a MeshRenderer component. The MeshFilter's shared mesh needs to be set to the object you created in Max.
public Mesh objectToCreate;
var gameObject = new GameObject("Some Name Here");
var meshFilter = gameObject.AddComponent<MeshFilter>();
meshFilter.sharedMesh = objectToCreate;
gameObject.transform.position = transform.position;
gameObject.transform.rotation = transform.rotation;
Answer by hdgam3r
Sep 10, 2012 at 01:58 PM
First of all, you must make a Prefab that contains your 3DS Max model.
Then, you just need to instantiate it by using Instantiate in your script, you can even pass the position where you want your object to spawn.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users post good questions and use the site effectively we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
11 People are following this question.
script dosnt creat object where i want it to
Tagging object while instating not working.
Mesh Filter change up
How can I assign a class to a script variable in the inspector?
Fading an object via script