球面上的主摄像头和播放器出现问题

时间:2018-08-26 15:10:47

标签: c# unity3d

我尝试创建一个玩家可以移动的圆形世界,玩家的代码是:

export class Messages extends React.Component {
    ....

    _handleOnClickYes(e){
        this.props.sendQuery("Yes");
        // then do something with e
    }

    _handleOnClickNo(e){
        this.props.sendQuery("No");
        // then do something with e
    }

    render(){
        return(
              <div>
                <table className="message_table>
                  {this.props.messages.map(msg => {
                      <tr className="msg-class"><td>{msg}</td></tr>
                      }
                  )}
        )
    }
}

并且工作完美,现在我尝试创建一个在循环世界中跟随玩家的相机,但是不能正常工作:

public class Player : MonoBehaviour {

    public float speed = 10f;
    private Rigidbody rb;

    private float horizontal = 0f;
    private float vertical = 0f;

    private void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update () {
        horizontal = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
        vertical = Input.GetAxis("Vertical") * speed * Time.deltaTime;
    }

    private void FixedUpdate()
    {
        Vector3 origin = Vector3.zero;

        Quaternion hq = Quaternion.AngleAxis(-horizontal, Vector3.up);
        Quaternion vq = Quaternion.AngleAxis(vertical, Vector3.right);

        Quaternion q = hq * vq;

        rb.MovePosition(q * (rb.transform.position - origin) + origin);
        transform.LookAt(Vector3.zero);
    }
}

1 个答案:

答案 0 :(得分:0)

这应该有效。在注释中内联说明:

print(x.to_string(index=False))