###前提・実現したいこと
Unityで任意の角度で左右に動く床を作りたい
###発生している問題・エラーメッセージ
ワールド座標のx軸では左右に動くのですがQuaternionを使ってほかの角度でも動かせるようにしようとしても上手くいきません。(角度を変えても動く軸がx軸のままになってしまいます)
###該当のソースコード using UnityEngine; using System.Collections; public class MovePlaneWidth : MonoBehaviour { public float speed; public float moveWidth; public PlayerMove player; private Rigidbody plane; private Vector3 basePosition; private float time; // Use this for initialization void Start() { basePosition = transform.position; plane = GetComponent<Rigidbody>(); time = 0; } // Update is called once per frame void FixedUpdate() { plane.MovePosition(basePosition + Quaternion.Euler(0, transform.eulerAngles.y, 0) * transform.right * Mathf.Sin(time) * moveWidth * Time.deltaTime); time += speed; if (time >= 360.0f) { time -= 360.0f; } } }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。