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 Artomix · Dec 15, 2013 at 09:44 PM · gamewithany

How to make a player change into other objects

Hello,

I've been doing unity for a long while now, but only the scripting part is still tricky. I am making a kind of a PropHunt game, and i need help with my JavaScript. I already have that when you click, you change into a object, but then you cant walk or move. i have seen alot of other unity forums and documents, but nothing helps. any help will be appreciated. thanks. My script:

 var player : GameObject;
 
 var Changer : GameObject;
 
 var AnimObject : GameObject;
 
 var Spawn_Position;
 
 function OnMouseUp(){
     Destroy(gameObject);
     Instantiate(Changer,AnimObject.transform.position,AnimObject.transform.rotation);
     }
 
     function Update ()
     {
     if(OnMouseUp == true){
         Instantiate(Changer,AnimObject.transform.position,AnimObject.transform.rotation);
         
     }
     }
     
     
 
Comment
Add comment · Show 1
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 tomekkie2 · Dec 15, 2013 at 10:00 PM 0
Share

I think you rather mean the mesh change http://answers.unity3d.com/questions/26894/how-do-change-the-mesh-of-a-game-object.html If you change the mesh - you still should be able to walk and move - provided it has the same animations you could still use and will ineract with other object in the same way.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Kiloblargh · Dec 15, 2013 at 09:54 PM

You're destroying the object with the script on it on mouse up. Any other scripts on that object will not work after that.

The code in Update() should not be there.

Variable names should be lowercase.

Here is the help with Javascript you need.

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 Artomix · Dec 19, 2013 at 07:47 PM 0
Share

Now i have changed the mesh in my script. and deleted the Destroy(gameObject); line. But what now? when click on the block that i want to become, ( its a standard cube) it says that it could not instantiate. Its very weird, and thanks for all the help, but it doesn't work, and I really would like to go on with my game. anyway, thanks alot guys, and hopefully we will sort this out.

avatar image
0

Answer by g0tNoodles · Dec 20, 2013 at 03:21 PM

You could change the mesh or have an empty parent object that has all the objects you wish to change in to as children. Depending on how you are planning on using the different objects you change in to (different skills for example), you could have a simple script that changes the player's form on the parent and then just make the other objects active or inactive.

No need to instantiate in my opinion, many people do something similar to the above. Easier just to turn some things on and off.

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

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Can I Make A Game launcher Using Unity 0 Answers

Beast lighting like mirrors edge. 1 Answer

Collecting Papers and Keeping Track of how many collected - need help 1 Answer

FPSMouseScript.js 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