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 /
This question was closed Dec 09, 2013 at 12:54 AM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by DeadKenny · Dec 08, 2013 at 11:24 PM · instantiateparticlesgetcomponentontriggerenterfor

Why is this GetComponent not working?

Its not getting the script here called ds on entering the trigger area. It detects the collider that hits it though I checked.

What it does is act as a trigger for an area of sand which your player passes over. Once within the area it is supposed to instantiate the particles at the transforms set in the vehicle.

So yeah whats going on?

Code:

     public ParticleEmitter groundTrailParticle;
         
 }
             
         
       void OnTriggerEnter(Collider other){
 
             
         if(other.tag == "car"){    
             
             groundTrailParticle.enabled = true;
 
 //The problem starts here.
 
                     CarController ds = other.GetComponent<CarController>();
 
         for(int i = 0; i < ds.wFx.Length; i++){
                 
                 
             Instantiate(groundTrailParticle, ds.wFx[i].position, ds.wFx[i].rotation);        
     
             
         }
             
         }
         



 
Comment
Add comment · Show 4
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 ozone · Dec 08, 2013 at 11:40 PM 1
Share

You have already initialized the variable ds, so there's no need to denote the type CarController on line 16. $$anonymous$$aybe that's messing things up? Also, it seems like the type you set when you initialize it is different than the type you set on line 16. That could also be a problem.

avatar image DeadKenny · Dec 09, 2013 at 12:01 AM 0
Share

Oh crap I made error in posting. ds is not supposed to be intitialized beforehand that was supposed to be edited out.

That is not the problem.

It runs and throws up reference not set error at line 16 when I enter the trigger.

avatar image ozone · Dec 09, 2013 at 12:06 AM 0
Share

I've never seen the syntax you use on line 15 with the CarController before the parentheses. That might just be because I am very inexperienced, but it could be worth a try to write it as other.GetComponent(CarController) ins$$anonymous$$d.

avatar image DeadKenny · Dec 09, 2013 at 12:10 AM 0
Share

Its C#, it has to be like that.

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by DeadKenny · Dec 09, 2013 at 12:33 AM

AH ok lol I found it. The component is in the Parent of the Object with collider in car.

  CarController ds = other.transform.parent.GetComponent<CarController>();


FIXED!!! Thanks though man.

Comment
Add comment · Show 2 · 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 meat5000 ♦ · Dec 09, 2013 at 12:35 AM 0
Share

lol accept the answer

avatar image DeadKenny · Dec 09, 2013 at 12:51 AM 0
Share

Lol, woops forgot.

Thanks.

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

Order of object instantiation scripting issues 0 Answers

Getting a component of an instantiated object returns an error 1 Answer

How do I re-instantiate original prefab after a game object inside has been destroyed? 2 Answers

Accessing Variable From Other Gameobject 1 Answer

Only 1 of 3 conditions being executed in IF statement?(Solved) 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