0

我想让它让我的玩家对象面向我的鼠标,这样他就可以射击东西。到目前为止,我拥有的代码只是旋转不稳定和错误。我究竟做错了什么?

    onMouseMove(m:EventMouse){
    var facing = new Vec2(
        m.getLocation().x - this.node.getPosition().x, 
        m.getLocation().y - this.node.getPosition().y);

    var angle = Math.atan2(facing.y, facing.x) * 180 / Math.PI;   

    this.node.setRotationFromEuler(new Vec3(0, 0, angle));
}
4

0 回答 0