- Home /
I found a way to LINK JS AND C# but i have 1 problem
okay so basically i linked my java script to my C# script via a gameobject BUT .....
You must basicall make the C# or Js dependent on the game object being in a rendered state or in a collider state .
this is how it is done .
(1) I created a game object named LinkSphere
(2) Created this Js
var LinkSphere : GameObject; // in the inspector i drag and drop the gameobject "link sphere" here.
function Update () {
LinkSphere = GameObject.Find("LinkSphere"); // i locate the game object
if (LinkSphere.collider.enabled == false){ // in the C# script there is a function that turns the "linkSphere" collider off
// if the C# script function is carried out then this happens
print ("WORKS LIKE A CHARM"); // this is printed out so i know it works BUT
// the rest of the codes function is not carried out , could you help :'(
GetComponent(motionscript).enabled = false; //"motionscript" is the js i want to link to my C# script
yield WaitForSeconds (20);
GetComponent(motionscript).enabled = true; // turn the Js back on
collider.enabled = true; // turn back on the collider } }
(3) THIS IS THE C# FUNCTION
// if the up arrow is held down for 1 second this happens
DONT PAY TO MUCH ATTENTION TO THIS
public static GameObject LinkSphere; // ...........
if ( Input.GetKey(KeyCode.UpArrow)){ count1-= Time.deltaTime ; if(count1<0){
print ("chopper");
LinkSphere = GameObject.Find("LinkSphere"); LinkSphere.collider.enabled = false; count1=3; }
NEVER $$anonymous$$IND I FIXED IT $$anonymous$$YSELF :)
Your answer
Follow this Question
Related Questions
Get game component type? 1 Answer
send message object variable 1 Answer
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer