猫史档案馆


【教程】视角的应用(全面)

用户:guxia666guxia666查看:965 回复:19 评论:2 创建时间:2022-10-11T10:20:11


首先大家应该都知道视角这个《东西》,那么今天我们就讲讲视角的所有的代码  * 1.第一视角(这个很简单并且API都有就不再讲述)

world.onPlayerJoin(({entity})=>{
entity.player.cameraMode = Box3CameraMode.FPS;
})
 * 2.第三视角(这个很简单并且API都有就不再讲述)
world.onPlayerJoin(({entity})=>{
entity.player.cameraMode = Box3CameraMode.FOLLOW;
})
* 3.隐藏API:2D视角(横面)
world.onPlayerJoin(async function({entity}){        
        entity.player.cameraMode=Box3CameraMode.RELATIVE;
        entity.player.cameraPosition=new Box3Vector3(-0.01,40,0);
        entity.player.swapInputDirection=true;
        entity.player.reverseInputDirection=Box3InputDirection.HORIZONTAL;
        entity.player.cameraFreezedAxis=Box3CameraFreezedAxis.Y;
        entity.player.freezedForwardDirection=new Box3Vector3(0,0,1);
});

效果图:

center_image

 * 4.隐藏API:2D视角(竖面)
world.onPlayerJoin(async({ entity })=> {
    //设置视角
    entity.player.cameraMode = "relative"
    entity.player.cameraTarget.y = 1
    entity.player.cameraPosition.set(0, 0, -15)//3个数随便调,假设是a1,a2,a3,那么这一行的意思就是指从x+a1,y+a2,z+a3的地方看你()
    //禁用WS
    entity.player.disableInputDirection = Box3InputDirection.VERTICAL;//这东西是禁止ws的
    entity.player.swapInputDirection = true//把这一行注释了后就可以搞事情了(?)
    //防止移动出错
    entity.player.freezedForwardDirection = new Box3Vector3(1, 0, 0);
    entity.collides.boolean = false
})

效果图:

center_image

 * 5.视角的缩放
world.onPlayerJoin(async({ entity })=> {
    entity.player.cameraFovY += 0.25;
})
 * 相信大家用了第4,5的代码后再切换第一视角,第三视角会出现锁视角的《特性》,所以:  * 6.解除锁视角
entity.player.swapInputDirection = false;
entity.player.freezedForwardDirection = null
entity.player.reverseInputDirection = Box3InputDirection.NONE
 * 下面就是神奇的fixed的用法  * 首先我先讲解一下fixed与4,5的区别哈  * 他与4,5的区别就是:4,5能够随着玩家的移动垂直于玩家的锁视角也随之移动,而fixed就有所不同,fixed是不随着玩家的移动而移动  * 那么我们知道区别了就开始fixed的用法  * (1)与4,5近似(2D) 首先我先讲一个 entity.player.cameraPosition,entity.player.cameraTarget的作用哈 entity.player.cameraPosition 是固定视角(FIXED)下,镜头的眼睛位置,entity.player.cameraTarget是固定视角(FIXED)下镜头所朝向的目标点,当然还有 cameraUp,cameraUp是固定视角(FIXED)下,镜头向上的矢量
world.onPlayerJoin(({entity})=>{
    entity.player.cameraMode=Box3CameraMode.FIXED;
    entity.player.cameraPosition = new Box3Vector3(44, 0, 144)
    entity.player.cameraTarget = new Box3Vector3(44, 0, 144)
    
})

数值的话大家自己调吧(作者懒)

* (2)《大片》视角的移动(重重之重)
world.onPlayerJoin(async function({entity}){       
                entity.player.directMessage('看完后自动关闭')
                entity.player.enableAction0 = false;
                entity.player.enableAction1 = false;
                entity.player.cameraMode = Box3CameraMode.FIXED;
                entity.player.animate([
                    { cameraPosition: new Box3Vector3(-22, 128, -22), cameraTarget: new Box3Vector3(-22, 20, -22), duration: 1 },
                    { cameraPosition: new Box3Vector3(150, 128, 150), cameraTarget: new Box3Vector3(0, 20, 0), duration: 1 },
                    { cameraPosition: new Box3Vector3(30, 128, 150), cameraTarget: new Box3Vector3(128, 20, 0), duration: 1 },
                    { cameraPosition: new Box3Vector3(30, 30, 150), cameraTarget: new Box3Vector3(128, 20, 0), duration: 1 },
                    { cameraPosition: new Box3Vector3(150, 30, 150), cameraTarget: new Box3Vector3(0, 20, 0), duration: 1 },
                    { cameraPosition: new Box3Vector3(150, 30, -22), cameraTarget: new Box3Vector3(0, 20, 128), duration: 1 },
                    { cameraPosition: new Box3Vector3(-22, 30, -22), cameraTarget: new Box3Vector3(128, 20, 128), duration: 1 },
                    { cameraPosition: new Box3Vector3(150, 128, 150), cameraTarget: new Box3Vector3(0, 20, 0), duration: 1 },
                    { cameraPosition: new Box3Vector3(172, 59, 209), cameraTarget: new Box3Vector3(28, 50, 150), duration: 1 },
                    { cameraPosition: new Box3Vector3(entity.position.x, entity.position.y + 1, entity.position.z), cameraTarget: new Box3Vector3(entity.position.x, entity.position.y, entity.position.z), duration: 1 },
                ], {
                    iterations: 1,
                    duration: 16 * 50,
                })
                await sleep(50 * 1000)
                entity.player.cameraMode = Box3CameraMode.FOLLOW;
                entity.player.enableAction0 = true;
                entity.player.enableAction1 = true;
})

好了,这一期的视角的应用就到此为止了

在最后我想问大家,你学废了么emotion_doge


回复

上一页第 1 页 / 共 1 页下一页
guxia666guxia666

喵d

点赞1


评论


ZNS_哪吒ZNS_哪吒

喵d()

点赞0


评论


guxia666guxia666

喵d

点赞1


评论


guxia666guxia666

喵d

点赞2


评论


盗码师盗码师

喵d

点赞1


评论

ddd


guxia666guxia666

喵d

点赞1


评论

awa


超级大帅哥本人超级大帅哥本人

玩家缩得很小之后的第三人称视觉会在玩家头顶正上方,怎么办?

点赞3


评论


busterbuster

咋没有cameraPich)))

点赞1


评论


传说之下ULB--sans传说之下ULB--sans

喵d

点赞0


评论


yee剑走天下yee剑走天下

喵d

点赞0


评论


37303730

ddd

点赞0


评论


喵喵咪awa喵喵咪awa

ddd

点赞0


评论


SCS_user_i1eril0dUySCS_user_i1eril0dUy

ddd

点赞0


评论


望柒望柒

ddd

点赞0


评论


一勺小汤_纪念号一勺小汤_纪念号

收藏emotion_编程猫_点赞

点赞0


评论


天员重来天员重来

center_imagecenter_imagecenter_image真神奇啊!!!!

点赞1


评论


天员重来天员重来

center_image

点赞0


评论


NelsonNelson

*收藏了

点赞0


评论


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

d d d

点赞0


评论