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メソッドの戻り値が常に一定になってしまいます。
何がいけないのかわからないです。
わかる人教えてください。