Показать сообщение отдельно
Старый 07.01.2013, 14:38   #53
mepihin
ПроЭктировщик
 
Регистрация: 31.12.2012
Сообщений: 165
Написано 5 полезных сообщений
(для 7 пользователей)
Ответ: Вотпросы от mepihin!

Вот блин вопрос:
Почему я не могу получить переменную из моего скрипта в Character Motor. То есть мне нужно использовать переменную из моего скрипта FPSController в моторе.
Делаю так:
private var fpscontroller GameObject;

function 
Awake () {
    
controller GetComponent (CharacterController);
    
tr transform;
    
fpscontroller GetComponent("FPSController");
}

function 
Update () {
    if (!
useFixedUpdate)
        
UpdateFunction();
    if(
Input.GetKey(KeyCode.LeftShift) && fpscontroller.speedactive == true)
    {
        
movement.maxForwardSpeed 6.0;
    }
    if(!
Input.GetKey(KeyCode.LeftShift) && fpscontroller.speedactive == false)
    {
        
movement.maxForwardSpeed 3.0;
    }
    else
    {
        if(!
Input.GetKey(KeyCode.LeftShift) && fpscontroller.speedactive == true)
        {
            
movement.maxForwardSpeed 3.0;
        }
    }
    if(
Input.GetKey(KeyCode.LeftShift) && fpscontroller.speedactive == false)
    {
        
movement.maxForwardSpeed 3.0;
    }

Пишет вот что:
Assets/Standard Assets/Character Controllers/Sources/Scripts/CharacterMotor.js(340,61): BCE0019: 'speedactive' is not a member of 'UnityEngine.GameObject'.
Во всех строках где это есть. Перменная такая существует!
Делал иначе:
if(Input.GetKey(KeyCode.LeftShift) && gameObject.transform.GetComponent("FPSController").speedactive == false)
    {
        
movement.maxForwardSpeed 3.0;
    } 
Пишет вот так:
Assets/Standard Assets/Character Controllers/Sources/Scripts/CharacterMotor.js(337,9: BCE0019: 'speedactive' is not a member of 'UnityEngine.Component'.
Еще вот так пытался:
transform.transform.GetComponent("FPSController").speedactive 
Аналогичная ошибка, что мне делать?
(Offline)
 
Ответить с цитированием