の別のスクリプトからスクリプトをオフにする必要がありますUnity
。スクリプトは にC#
あり、オフにするスクリプトは にありJS
ます。両方のスクリプトが同じオブジェクトに関連付けられています。私が受け取っているエラーは、有効になっているようなものがないことを示しています。何かご意見は?以下は私のコードの一部です。
void Update ()
{
var walkScript = GameObject.FindWithTag ("Player").GetComponent ("CharacterMotor");
if ((Input.GetKey ("p")) && (stoppedMovement == true)) {
stoppedMovement = false;
walkScript.enabled = true;
} else if ((Input.GetKey ("p")) && (stoppedMovement == false)) {
stoppedMovement = true;
walkScript.enabled = false;
}
私が受け取っているエラーは次のとおりです。
Assets/Standard Assets/Character Controllers/Sources/Scripts/MouseLook.cs(41,36): error CS1061: Type
UnityEngine.Component' does not contain a definition for
enabled' and no extension methodenabled' of type
UnityEngine.Component' could be found (using ディレクティブまたはアセンブリ参照がありませんか? )