猫史档案馆


【Box3】求助 如何做出汽车行驶的效果?

用户:SHEL深空无尽SHEL深空无尽查看:2 回复:4 评论:2 创建时间:2021-07-23T15:13:13


如何让一个叫做车的实体在x0一直向前开,开进虚空后又传送回x0,继续往前开?

可以去看布灵岛的公路,就是那个效果

特急


回复

上一页1 页 / 共 1下一页
成熟的强袭编程猫548成熟的强袭编程猫548

不是宅宅帮你写了吗

点赞0


评论


azzzz代码师azzzz代码师

world.onPlayerJoin(({ entity }) => {//当玩家进入时
/
const originPlayerMesh = entity.mesh;//玩家
world.onInteract(({ entity, targetEntity }) => {


if (targetEntity.mesh.match("car") != 0) {
entity.mesh = targetEntity.mesh;//玩家模型变成车
entity.meshScale = targetEntity.meshScale;//大小一致
entity.meshOrientation = targetEntity.meshOrientation;
entity.position = targetEntity.position;//位置
targetEntity.destroy();//原来的车销毁
entity.player.invisible = true;
}

});
///上车
world.onPress(({ button, raycast }) => {
if (button === 'crouch') {
const origincar = entity;

//车
world.createEntity({
id: "car",
mesh: origincar.mesh,
mass: origincar.mass,
friction: origincar.friction,
position: origincar.position,
meshScale: origincar.meshScale,
restitution: origincar.restitution,
meshOrientation: origincar.meshOrientation,
collides: true,
gravity: true,
fixed: true,
})
//world.createEntity(car);

entity.mesh = originPlayerMesh
entity.player.invisible = false;//人物变为原来 注意顺序
}
})

})
world.onEntityCreate(({ entity }) => {//此时的entity的模型为载具
if (entity.mesh.match("car") != 0) {
//console.log("是车");
entity.enableInteract = true; // 开启实体互动功能
entity.interactRadius = 8; // 互动范围大小
}
})
world.onEntityContact(({ entity, other }) => {//当一个实体碰撞到另一个实体时

})

点赞0


评论


YLG_個YLG_個

我也想要()

点赞0


评论


SHEL深空无尽SHEL深空无尽

az不要挖坟aaa((

点赞0


评论