HI everyone! I have a Ford Pickup, in this object, i have “sub items”.
WheelRL
WheelRR
WheelFL
WheelFR
TRIGGER
In the trigger, i have this script:
var guiEnable = false;
var camioneta : GameObject;
// GUI
function OnGUI(){
GUI.depth = 0;
if (guiEnable){
GUI.Label(Rect(70,40,330,50), "Presiona F para entrar al coche");
}
}
function OnTriggerEnter (myTrigger : Collider) {
if (myTrigger.name == "Player") guiEnable = true;
if(Input.GetKey("f")){
// I need the code for activate the script "Conduccion"
}
}
function OnTriggerExit (myTrigger : Collider) {
if (myTrigger.name == "Player") guiEnable = false;
}
And, in the Ford Pickup, i have this script:
var rearWheel1 : WheelCollider;
var rearWheel2 : WheelCollider;
var frontWheel1 : WheelCollider;
var frontWheel2 : WheelCollider;
var steer_max = 20;
var motor_max = 10;
var brake_max = 100;
private var steer = 0;
private var motor = 0;
private var brake = 0;
function FixedUpdate () {
...
}
As I can activate from the object “son”, a script located in the parent object?
This code dont have error. I have one script in the “Forus Pickup” named: “Conduccion”. This script are desactivate.
The script “coches” not enable the script conduccion, location in the parent. The code in the script “coches” is this:
var guiEnable = false;
var camioneta : GameObject;
// GUI
function OnGUI(){
GUI.depth = 0;
if (guiEnable){
GUI.Label(Rect(70,40,330,50), "Presiona F para entrar al coche");
}
}
function OnTriggerEnter (myTrigger : Collider) {
if (myTrigger.name == "Player") guiEnable = true;
if(Input.GetKey("f")){
transform.parent.transform.GetComponent(Conduccion).enabled = false;
}
}
function OnTriggerExit (myTrigger : Collider) {
if (myTrigger.name == "Player") guiEnable = false;
}
but, this way, the script does not activate target …