用户:
hecos查看:53 回复:22 评论:53 创建时间:2020-04-19T16:31:43
world.onEntityContact(({entity,other})=>{
if(entity.isPlayer===false){
if(other.isPlayer===true){
if(entity.hasTag('car')){
if(other.mesh===''){
other.meshOrientation = new Box3Quaternion(0, 1, 0, 0);//调整方向
other.mesh=entity.mesh;
other.meshScale=entity.meshScale;
other.player.canFly=false;
other.player.invisible=true;
other.player.walkSpeed=2;
other.player.runSpeed=3;
}
}
}
}
});
给车加上car的标签
然后就可以正着开车啦!


world.querySelectorAll('.ofcar').forEach((e)=>{
e.onEntityContact(({other})=>{
other.player.mesh='';
other.player.invisible=false;
other.player.walkSpeed=0.22;//正常行走速度
other.player.runSpeed=0.4;//正常奔跑速度
other.player.canFly=false;
})
})//此代码不仅用于下车,也用于下任何交通工具,甚至不是交通工具点赞0
评论
BSS梅者如西额,补充一下飞机的代码,望置顶。首先先把模型加上“飞机”的标签,然后在代码栏里输入一下代码
world.onEntityContact(({entity,other})=>{
if(entity.isPlayer===false){
if(other.isPlayer===true){
if(entity.hasTag('.飞机')){
if(other.mesh===''){
other.meshOrientation = new Box3Quaternion(0, 1, 0, 0);//调整方向
other.mesh=entity.mesh;
other.meshScale=entity.meshScale;
other.player.canFly=true;
other.player.invisible=true;
other.player.walkSpeed=2;
other.player.runSpeed=3;
}
}
}
}
});点赞0
评论
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true;
entity.player.onPress(({ button, raycast:{ hitEntity, direction } }) => {
if (button !== 'action0' || !hitEntity) {
return;
}
hitEntity.velocity.x += direction.x;
hitEntity.velocity.y += 0.5;
hitEntity.velocity.z += direction.z;
hitEntity.hurt(5 * Math.random() + 5, {
attacker: entity,
});
});
});
//检测攻击代码
world.onDie(({ entity, attacker }) => {
if (attacker) {
world.say(attacker.player.name + ' 击杀了 ' + entity.player.name)
}
entity.player.forceRespawn();
});//死亡后代码
枪战代码![]()
点赞0
评论