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 ibayibay1 · Feb 09, 2013 at 10:26 PM · collidercollidersupgrade

Object upgrades character?

so i have a custom 3rd person character i made. i have a particle effect attached to him so that when mouse down, it will show. the result is whenever you click it will appear as if he is spitting fire. I want it so that when the character walks over an object, the fire he was spitting disapears and a different effect appears. however I am having some trouble understanding what colliders and triggers need to go on what and how i would call on those from script and switch the particle effects.

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
Best Answer

Answer by ThePunisher · Feb 09, 2013 at 11:01 PM

Does your character use the CharacterController? If so then he should have a rigidbody (if not he'll need one). Now all you need to do is attach collider to the object he will "pick up".

For example, let's say that you have a pill as a powerup. You can attach a box collider to the pill and size it so that it fights tightly on the pill. Then you check isTrigger on the collider component (in the inspector for the pill), which makes it to where your player doesn't actually collide with the pill and instead simply notifies the pill that it has entered its collider. This will allow you to handle the collision yourself.

Now all you have to do is script the events you mentioned.

 public class PillScript : MonoBehaviour
 {
     void OnTriggerEnter(Collider other)
     {
         if(other.tag == "Player")
         {
             // Get the special script on your player that allows you to control it.
             YourMagicalScript yms = other.gameObject.GetComponent<YourMagicalScript>();
 
             // Disable the fire effect (store/find a reference to it so that you can grab from your character here)
             yms.FireEffect.enabled = false;
             yms.DifferentEffect.enabled = true;
 
             //And if you want the pill to go away, then all you have to do is call destroy on this scripts GameObject.
             Destroy(gameObject);
         }
     }
 }
Comment
Add comment · Show 3 · 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 ThePunisher · Feb 09, 2013 at 11:02 PM 0
Share

That code is in c# but the logic is the same no matter what, you'll just need to look up the syntax if you use java.

avatar image ibayibay1 · Feb 12, 2013 at 02:45 AM 0
Share

this helped me understand how i should use colliders properly with OnTriggerEnter thanks.

avatar image ThePunisher · Feb 12, 2013 at 05:39 PM 0
Share

If it helped answer your question can you please mark the answer as correct.

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

10 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

Related Questions

raycasts only working with IsTrigger colliders? 1 Answer

A script that auto generated the box collider around a 3d model 3 Answers

How can I change animation with colliders? Using AR and Vuforia. 0 Answers

OnCollisionEnter2D is not working 0 Answers

npc collider 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