猫史档案馆


[Box3]移动端优化之自动视角1.0

用户:145a145a查看:11 回复:13 评论:11 创建时间:2023-03-11T12:51:59


众所周知,移动端换视角会干扰其他操作,很不方便

这段代码可以让用户通过摇杆切换视角

感谢互助群里@冷鱼与热猫@AMC两位大佬对我的指点

(本人萌新,大佬勿喷)

//Box3Entity.prototype.autoCamera():void
Box3Entity.prototype.autoCamera = function () {
    this.player.cameraMode = "fixed";
    this.player.cameraPosition = this.position.sub(this.player.facingDirection.scale(20)).add(new Box3Vector3(0, 10, 0));
    this.cameraFlash = world.onTick(() => {
        const targetPos = this.position.sub(
            this.player.facingDirection.scale(20)
        ).add(
            new Box3Vector3(0, 5, 0)
        )
        if (targetPos.distance(this.player.cameraPosition) > 1) {
            this.player.cameraPosition.addEq(this.player.cameraPosition.towards(targetPos).scale(0.1))
        }
        this.player.cameraTarget.copy(this.position);
    });
}


回复

上一页1 页 / 共 1下一页
梁桂琪梁桂琪

我打算开新图了,做不做

点赞0


评论


mkonnzikmkonnzik

    

点赞0


评论


145a145a

喵d

点赞0


评论


145a145a

使用移动端全屏即可体验

点赞0


评论


神奇代码岛func王清林神奇代码岛func王清林

ddd

点赞0


评论


名探酱名探酱

这不仅仅是移动端方便,电脑也会方便,ddd

点赞0


评论


SCS_user_rbxaHQh5aOSCS_user_rbxaHQh5aO

瓦特?

点赞0


评论


SCS_user_rbxaHQh5aOSCS_user_rbxaHQh5aO

啊这

点赞0


评论


SCS_user_rbxaHQh5aOSCS_user_rbxaHQh5aO

我也叫紫灵2

点赞0


评论


SCS_user_rbxaHQh5aOSCS_user_rbxaHQh5aO

头像都一样

点赞0


评论


judgment04judgment04

所以为什么我用不了呢……emotion_编程猫_溜了溜了

点赞0


评论


灵除草寄灵除草寄

感受痛苦吧。

点赞0


评论


Dreamland_AuroraDreamland_Aurora

24小时在线啊()

点赞0


评论