用户:
治愈绾兮查看:498 回复:13 评论:23 创建时间:2021-08-01T13:06:34
制作过山车,说白了就是玩家移动(这句话是宅宅说的),因此,我们可以用position.set让玩家不断移动到过山车轨道上。
首先,我们需要建一个过山车轨道,并且按照过山车移动的顺序给轨道从1到n命名;
然后,开始写代码。
代码第一步:设置坐过山车的条件,这里假设在玩家进入地图时坐过山车1圈,那么代码框架就是:
world.onPlayerJoin(async ({ entity }) => {
});
代码第二步:如果要让玩家不断移动到下一个轨道上,就需要让玩家自己不能动,并且不受重力影响,如果用canFly是不行的,因为飞行打开的话玩家是可以控制自己飞不飞的,因此,需要设置玩家为幽灵模式,并且为了让他自己不能动,要把飞行速度和加速度调为0,也就是:
world.onPlayerJoin(async ({ entity }) => {
entity.player.spectator = true;
entity.player.flySpeed = 0;
entity.player.flyAcceleration = 0;
})
然后,就是重点,要让玩家不断移动到下一个轨道上,其实并不难,直接看代码:
world.onPlayerJoin(async ({ entity }) => {
entity.player.spectator = true;
entity.player.flySpeed = 0;
entity.player.flyAcceleration = 0;
for (let i = 1; i <= 100; i++) {//这里的100表示有100个轨道,可以自行调整
entity.position.set(world.querySelector("#" + String(i)).position.x, world.querySelector("#" + String(i)).position.y + 2, world.querySelector("#" + String(i)).position.z)
await sleep(100)
}
})
最后,重置玩家的数据:
world.onPlayerJoin(async ({ entity }) => {
entity.player.spectator = true;
entity.player.flySpeed = 0;
entity.player.flyAcceleration = 0;
for (let i = 1; i <= 100; i++) {
entity.position.set(world.querySelector("#" + String(i)).position.x, world.querySelector("#" + String(i)).position.y + 2, world.querySelector("#" + String(i)).position.z)
await sleep(100)
}
await sleep(1000)//这里的等待1秒是为了让玩家坐完过山车后等1秒再下车
entity.player.spectator = false;
entity.player.flySpeed = 2;
entity.player.flyAcceleration = 2;
entity.position.set(喵, 10, 喵)//这是坐完过山车后要去的位置,可以自行调整
})
好了,以上就是全部代码,下面是白嫖时间:
world.onPlayerJoin(async ({ entity }) => {
entity.player.spectator = true;
entity.player.flySpeed = 0;
entity.player.flyAcceleration = 0;
for (let i = 1; i <= 100; i++) {
entity.position.set(world.querySelector("#" + String(i)).position.x, world.querySelector("#" + String(i)).position.y + 2, world.querySelector("#" + String(i)).position.z)
await sleep(100)
}
await sleep(1000)
entity.player.spectator = false;
entity.player.flySpeed = 2;
entity.player.flyAcceleration = 2;
entity.position.set(喵, 10, 喵)
})
小提示,轨道之间间距越短,间距越均匀,效果越好。
BSS梅者如西有做游乐园的吗
点赞0
评论
我还买了个游戏《过山车之星》
space.bilibili.com/7450650/channel/detail?cid=95180&ctype=0
我做过游乐园了
有吃瓜链接吗
看顶楼
好耶()
治愈绾兮在这里打个广告:岛3第一个全图可交互游乐园正式内测啦!https://box3.cod喵/e/a485b377c7c6619f2913
点赞0
评论
你能到我这个地图当代码师么?论坛地址:https://shequ.codemao.cn/community/389547
NO
hhh
az。。。。。。。。。。宅宅本宅路过,电脑那天坏了。。。。现在才修好。。。
点赞0
评论
你不是宅宅吧,我说的是宅宅梦想家
我就是宅宅梦想家!!!!!!!!!!!!!我只是社区的名字跟岛3的名字不一样了、。。。。。
哦,好吧
()()()()()