Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

enter and exit script problem

Discussion in 'Scripting' started by casebase, Mar 9, 2015.

  1. casebase

    casebase

    Joined:
    Mar 9, 2015
    Posts:
    6
    Can you get component from a cscript from a java script or do they have to be the same language?Because i have a vehicle exit and enter script that is a javascript that i would like to use with a vehicle control script.
     
  2. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,739
    You can GetComponent a JavaScript just like you can c#
     
  3. casebase

    casebase

    Joined:
    Mar 9, 2015
    Posts:
    6
    But one of the scripts is java and one is c.Is it possible to get component from a cscript from a javascript?
     
  4. PJRM

    PJRM

    Joined:
    Mar 4, 2013
    Posts:
    303
    You may have a JScript "EnemyCore" attached to an object and a C# "EnemyIA" attached to the same.
    in both you can:
    Code (CSharp):
    1. GetComponent<EnemyCore>().DoSomething();
    Hope this help you!
     
  5. casebase

    casebase

    Joined:
    Mar 9, 2015
    Posts:
    6
    But can i do it if the javascript is on one object and the cscript is on the other?
     
  6. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Yes, it works.