前提・実現したいこと
メインカメラの座標が移動したらそれに合わせてオブジェクトのX、Z方向を移動する
y軸は移動しない
発生している問題・エラーメッセージ
エラー CS1955 実行不可能なメンバー 'Vector3' をメソッドのように使用することはできません。 エラーがどうして出るか、解決策が知りたい
該当のソースコード
using System.Collections; using System.Collections.Generic; using UnityEngine; public class move : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { this.transform.position = Vector3(Camera.main.transform.position.x, 0 ,Camera.main.transform.position.z); } }
試したこと
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class move : MonoBehaviour
{
void Start() { } void Update() { Transform a = this.transform; Vector3 point = a.position; point.x = Camera.main.transform.position.x; point.y = 0f; point.z = Camera.main.transform.position.z; a = point; }
}
別形式でも書いてみたが
エラー CS0029 型 'UnityEngine.Vector3' を 'UnityEngine.Transform' に暗黙的に変換できません
のエラーが出てよくわかない
補足情報(FW/ツールのバージョン2など)
unity 2019.2,17f1
ここにより詳細な情報を記載してください。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/17 14:43