【3Dゲームエンジン】Unity質問スレッド3at GAMEDEV
【3Dゲームエンジン】Unity質問スレッド3 - 暇つぶし2ch172:名前は開発中のものです。
12/12/02 12:19:41.09 R87cK3aN
カメラの位置を変更できなくて困っています。
void Start () {
// target is settinged in inspector
this.transform.LookAt(target);
}
void Update () {
// 1 = MouseRightButton
if( Input.GetMouseButton(1)) {
Vector3 tra = this.camera.ScreenToWorldPoint(Input.mousePosition);
Vector3 v = Vector3.Normalize(tra - target.position) * 5.0f;
this.transform.position = v;
this.transform.LookAt(target);
}
}

以上のコードを書いてメインカメラにアタッチしてtargetには適当なオブジェクトの位置を入れています、
Input.mousePositionはちゃんとスクリーン座標が入ってきているみたいですが
ScreenToWorldPointメソッドの戻り値が常に一定になってしまいます。
何がいけないのかわからないです。
わかる人教えてください。


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch