Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
1
Question by omgitstotallyme123 · Aug 15, 2015 at 03:55 AM · collisionmeshesswitchingswapping

Swap Mesh upon Collision?

Hello everyone! I'm making a modified roll-a-ball game for class, and I've run into a bit of trouble with one of the features I wanted to include. Instead of making meshes disappear upon collision, I want that mesh to change into something else. It would still behave the same as the previous mesh, and be of a similar size, it would just look different.

I'm not sure how how to set up or trigger this change. Any tutorials or advice?

Much appreciated!

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
1

Answer by Flickayy · Aug 15, 2015 at 09:09 AM

You'll want to take a look at the MeshFilter component for this kinda thing.

From this, you can then call MeshFilter.mesh.

By using mesh property you can modify the mesh for a single object only. The other objects that used the same mesh will not be modified.

Can't really give an example right now, but I'll come back and update this post later after I've woken up, hope this info helps.

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
Wiki

Answer by DrakoRex11 · Aug 15, 2015 at 02:09 PM

I am going to guess that you are using unity's physics engine?

try this.

 //up top above all of your methods(but before your header)
 
 public mesh mesh1;
 //2,3, etc as many as you want.
 //just copy that line and rename
 int state = 0;
 int SMAX = 2;//maximum number of meshes (changeable)

 void OnCollisionEnter (Collision collision) {
       if(state == 0){this.gameObject.GetComponent<MeshFilter>().mesh = mesh1;}
 //else if(state == 1){this.etc add mesh 2 here.

       if(state < SMAX){state++;}
       else{state = 0}

 
         }



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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How can I get the closest point on a concave mesh to a world position? 0 Answers

How do I make my mesh collider more accurate? 1 Answer

Colliding to mesh seams when shouldn't 0 Answers

Swappable clothing and armor help 1 Answer

Swapping Textures vs Swapping Meshes 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