Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

【質問】Unityのerror CS1002について

【質問】Unityのerror CS1002について

ここに解決したい内容を記載してください。

Unity初心者です。
Unityで回転できる範囲を制限するスクリプトを書いています。
角度を変更するスクリプトを書いているときにエラーが発生しました。
解決方法を教えて下さい。

現在発生しているエラー

Assets\Scenes\hogehoge.cs(24,46): error CS1002: ; expected

該当するソースコード

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class hogehoge : MonoBehaviour
{
    const float Min = -150;
    const float Max = 150;

    void Start()
    {

    }

    void Update()
    {
        float X = 0;

        if (Input.GetKey("right") == true);
        {
            X = Mathf.Clamp(transform.localRotation.x + 15, Min, Max);
        }

        transform.localRotation = Quaternion new Vector3 (X, 0, 0);
    }
}

自分で試したこと

CS1002は変数の宣言で;がないときに出力されると聞いたので、セミコロンを付け外ししてみました。(特に数字や変数の前後)
参考:https://docs.microsoft.com/ja-jp/dotnet/csharp/misc/cs1002
結果:CS1525やCS0119にエラーメッセージは変わったが、解決はしませんでした。

tabが関係あるのではないかと思い、tabの数を変更してみました

結果:変化なし

参考サイト

【Unity】Mathf.Clampを使って移動範囲を制限する http://kerotan-factory.xblog.jp/article/470090926.html
【Unity】回転の方法が一目でわかる !transform.Rotateを極めよう! https://www.sejuku.net/blog/51521
0 likes

1Answer

transform.localRotation = Quaternion new Vector3 (X, 0, 0);

このステートメントで作りたいのはクオータニオンですか?ベクターですか?

0Like

Your answer might help someone💌