用户:
YDS尹子查看:84 回复:58 评论:84 创建时间:2020-05-30T12:15:01
YDS尹子公开代码:
(有一些代码之外的准备事项:
1.放置模型,添加标签“gb2”
(模型的话是一面墙一个,这样中间才能站人)
2.把模型放置到合适位置
注意:若行驶方向不对请修改Velocity的方向
)
(async function(){
while (true) {
for(let i=0;i<15;i++){//火车向前加速
world.querySelectorAll(".gb2").forEach((entity)=>{
entity.velocity.z-=0.1;
})
await sleep(120)
}
await sleep(4500)//行驶中
for(let i=0;i<15;i++){//火车向前减速
world.querySelectorAll(".gb2").forEach((entity)=>{
entity.velocity.z+=0.1;
})
await sleep(120)
}
await sleep(3000)//停站中
for(let i=0;i<15;i++){//火车向后加速
world.querySelectorAll(".gb2").forEach((entity)=>{
entity.velocity.z+=0.1;
})
await sleep(120)
}
await sleep(4500)//行驶中
for(let i=0;i<15;i++){//火车向后减速
world.querySelectorAll(".gb2").forEach((entity)=>{
entity.velocity.z-=0.1;
})
await sleep(120)
}
await sleep(3000)//停站中
} })();
world.querySelectorAll(".gb2").forEach((entity)=>{
entity.friction=1;
})点赞0
评论
楼主楼主~
我弄了一个火车不会移出世界的代码~
↓
(async function(){
while (true) {
for(let i=0;i<15;i++){//火车向前加速
world.querySelectorAll(".gb2").forEach((entity)=>{
entity.velocity.z-=0.07;
})
await sleep(120)
}
await sleep(4500)//行驶中
for(let i=0;i<15;i++){//火车向前减速
world.querySelectorAll(".gb2").forEach((entity)=>{
entity.velocity.z+=0.07;
})
await sleep(120)
}
await sleep(3000)//停站中
for(let i=0;i<15;i++){//火车向后加速
world.querySelectorAll(".gb2").forEach((entity)=>{
entity.velocity.z+=0.07;
})
await sleep(120)
}
await sleep(4500)//行驶中
for(let i=0;i<15;i++){//火车向后减速
world.querySelectorAll(".gb2").forEach((entity)=>{
entity.velocity.z-=0.07;
})
await sleep(120)
}
await sleep(3000)//停站中
} })();
world.querySelectorAll(".gb2").forEach((entity)=>{
entity.friction=1;
})
把速度调成0.07~
就可以哦~
点赞0
评论