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 Dfrizzle · Feb 13, 2012 at 11:00 PM · collisioncollidergamenewbie

how to morph character on collision enter with gameobject

Hey there I been researching about how to do this but I cant seem to find a way. What i want is my player to collide with a gameobject which then changes to another character. any suggestions people ? Would really appreciate it as I am still in my learning stages of unity :)

I need to do this without using c# because we havent learnt that yet :)

kind regards Daniel Fry

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by adrenak · Feb 14, 2012 at 04:34 AM

I feel that a good way to do this would be to destroy the current charactor and instantiate a new (another) character in its place. Although there are different ways, but this is how I would have done :

 var differentCharactor : GameObject; //add the charactor *prefab* in this variable through the editor
 var posToSpawn : Transform;
 function OnTriggerEnter(other : Collider){
 
     if(other.gameObject.tag == "player")
         posToSpawn.position = other.gameObject.transform.position ; //record the character's position
         Instantiate(differentCharactor , posToSpawn.position, other.gameObject.transform.rotation); //instantiate prefab at same position and with same rotation
         Destroy(other.gameObject); //destroy the old charactor
     }
 }

I have assumed that the gameobject that changes the character has a trigger collider and the player has a tag called "player".

I Hope this helps!

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 Dfrizzle · Feb 15, 2012 at 01:36 PM 0
Share

Thanks it works so well, The great thing is I actually understand the code fully as well :).

I got it functioning in my work so when my player collides with the object it will create a new player and destroy the old and the object collided with. I was wondering how I would switch the main cameras target on collision with the object, so my camera follows my new character.

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

6 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

Issues with Translations and OnTriggerExit 0 Answers

Problem with acclerometer 0 Answers

Problem with jcar script for android mobile 1 Answer

How do I check if an object is touching another object? 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