Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Zylar · Jan 08, 2011 at 01:06 AM · meshfpslayersguncombinechildren

How do I ensure Combined Children Meshes are on the layer I want?

I'm making a simple fps. So I downloaded this pistol mesh I found. This pistol is made up of many (92) smaller meshes, and predictably draw count was too high. So I put the combine children script on the pistol mesh's parent object. Worked like a charm.

I also placed the pistol (parent and children) in a separate layer so that a secondary camera can draw the pistol over everything else.

However, whenever I play test the game the newly created combined children meshes are on the default layer, thus losing the desired effect.

So my question is basically : How can I make the children meshes to be on any layer I choose? How can I make sure that they will be made in the correct layer? I am expecting the solution to be in the form of some script, or editing the combine children script, but I don't know how to go about this. Help please!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Zylar · Jan 09, 2011 at 01:52 AM

Okay so after sleeping on it and doing a little research, I've come up with two solutions.

The first solution is to swap everything layer-wise. Have the gun on the default layer, which my camera draws on top of the second layer where every other game object will be.
This isn't the best way to handle it and has a couple of downsides.
The best way is to modify the combined children script.

There wouldn't have been an issue if all the meshes had the same material, since the script makes the parent object take upon itself the combined mesh of all its children. So if I wanted to make sure the combined mesh went on a certain layer, I would simply have to change the parent's layer in the editor.

But since they have more than one material, the script has to make objects in order for them to take the meshes. And you can't adjust these objects that aren't even created yet in the editor, you'll have to edit them in the script.

So where you find this in the script :

        else
        {
            GameObject go = new GameObject("Combined mesh");
            ...

Add this somewhere in the else statement (but not the top) :

        go.gameObject.layer = layerid;

Layerid is the number of the layer you want to place the gameobjects in.
So yeah, all it took was a simple addition to the script! xD

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Jason B · Jan 08, 2011 at 03:53 AM

This may be slightly sidestepping the question, but is there a particular purpose that the pistol be made up of 92 (?!) tiny meshes?

It sounds like it'll be a nightmare just having all those Game Objects floating around when it's not necessary, I'm thinking just for cleanliness and workflow's sake.

Firstly I'd try finding a better-made model before you decide you want to fiddle with a broken apart one that isn't broken apart for any good reason. If you need a better place to find models, there's always TurboSquid, just search and filter for free stuff. I'm sure there are quite a few good free ones to get (I've casually sold my models there for a while so I know there's a wide selection).

If you don't want to use a different one, I'm not sure how to fix the original problem at hand as I haven't got much experience using combined meshes and layers.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Zylar · Jan 08, 2011 at 04:52 PM 0
Share

Well, it was the first decent plain pistol I found. xD I've had no problem working with it; they are all properly positioned, parented, and combined children breaks it down to about 5 meshes. Its not "broken down" or bad, it just has a lot of parts. This particular pistol was made in google sketch-up exported to blender and exported to unity. (Unity wouldn't accept it from sketch-up) I dunno if that's why there's so many meshes. And regardless of if I'm going to pick another model, I'm interested to know how to influence combined children meshes. Thanks for the reply though! :]

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

I need help with my script 3 Answers

how to keep 1 audio listener 1 Answer

Flamethrower help 0 Answers

Collisions on gun affect players movement 1 Answer

how to make bullets apply damage 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges