- Home /
Question by
StyledStick · Sep 28, 2015 at 06:13 PM ·
gameobjectmeshmodelmodify
How to change a GameObject Mesh?
I am trying to do a FPS game, very simple thing, just for test the Unity Engine. Then, I made a script about player's inventory and weapon switching, using Javascript and everything that I know about it. But I got a problem, maybe the solution is very simple but I can't find it: How to switch a GameObject Mesh? Because I need to change the player's weapon. If someone can help me, thanks a LOT!
Comment
gameObject.GetComponent<$$anonymous$$eshFilter>().mesh = new$$anonymous$$esh;
http://docs.unity3d.com/ScriptReference/$$anonymous$$eshFilter.html
I also think there's more to a weapon then just the $$anonymous$$esh. Ammo type, the anchors where the hands go, muzzle position, animation... make your different weapons whole gameobjects and swap em around as a whole.