【3Dゲームエンジン】Unity質問スレッド3at GAMEDEV
【3Dゲームエンジン】Unity質問スレッド3 - 暇つぶし2ch283:名前は開発中のものです。
12/12/19 14:08:00.74 DcSTQ+Yo
すみません。初心者です。アクションゲームぽいものを作成しています。
プレイヤーの背後からカメラで写すといったところまでは出来たのですが、
velocityをローカル座標からワールド座標に変換するところではまっています。
やりたいことはゼルダのようなキャラが向いた方向にカメラが向くといった内容です。
左を押したらカメラから見て左に移動する。左を押し続ければ円を描くように左周りする。
以下のスクリプトでローカル座標からワールド座標に変換する位置?がわかりません。。
めっちゃ回転したりする。どうしたらいいのでしょうか?

public class PlayerController : MonoBehaviour {
public CharacterController controller;
public float gravity = 20.0f;

void FixedUpdate () {
Vector3 moveDirection = Vector3.zero;
moveDirection.y -= gravity;

Vector3 targetDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

if (targetDirection.magnitude > 0.1) {
transform.rotation = Quaternion.LookRotation(targetDirection);
moveDirection += transform.forward*2;
animation.CrossFade("Run");
// moveDirection = transform.TransformDirection(moveDirection);
} else {
animation.CrossFade("AttackStandy");
}
controller.Move(moveDirection*Time.deltaTime);
}
}


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