用户:
SHEL深空无尽查看:2 回复:4 评论:2 创建时间:2021-07-23T15:13:13
如何让一个叫做车的实体在x0一直向前开,开进虚空后又传送回x0,继续往前开?
可以去看布灵岛的公路,就是那个效果
特急
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
评论