猫史档案馆


玩家怎么发射子弹,火球,炮弹之类的实体教程

用户:高锰酸甲高锰酸甲查看:8 回复:15 评论:8 创建时间:2021-04-19T13:29:41


  for (const e of world.querySelectorAll('*')) { //遍历每个实体 e.enableDamage = true //允许这个实体 受伤/喵亡/复活 }

 

function spawnEntity(x,y,z,meshName){

 

  const meshScale = 1/10 //默认模型方块大小倍数为地图方块的1/16,看你实体的大小

 

  return world.createEntity({

 

    mesh:meshName,//模型名

 

    collides:true,//能碰撞

 

    fixed:false,//固定

 

    gravity:false,//受重力影响

 

    meshScale:[meshScale,meshScale,meshScale],//xyz放大倍数

 

    position:[x,y,z],//位置坐标

 

  })

 

}     world.onPress(({ button, entity, raycast }) => { if(button ==='action0'){//判断是否按了左键(action1是右键) console.log(` ${entity.player.name} 按下了左键`); var ball = spawnEntity(entity.position.x+raycast.direction.x, entity.position.y+raycast.direction.y, entity.position.z+raycast.direction.z,"mesh/火球.vb");//发射模型的名称 ball.velocity.x += raycast.direction.x*3; ball.velocity.y += raycast.direction.y*3; ball.velocity.z += raycast.direction.z*3;//把乘数放大可以让实体飞得更快!注意xyz放大的数都要一样!!! } })


回复

上一页1 页 / 共 1下一页
高锰酸甲高锰酸甲

world.onPress(({ button, entity, raycast }) => {        if(button ==='action0'){           console.log(` ${entity.player.name} 按下了左键`);           var ball = spawnEntity(entity.position.x+raycast.direction.x, entity.position.y+raycast.direction.y,                                        entity.position.z+raycast.direction.z,"mesh/火球.vb");           ball.velocity.x += raycast.direction.x*3;           ball.velocity.y += raycast.direction.y*3;           ball.velocity.z += raycast.direction.z*3;        } })     上面代码没空行所以重发一下

点赞1


评论


高锰酸甲高锰酸甲

center_image

后面有点长,下图center_image

点赞0


评论


高锰酸甲高锰酸甲

center_image

点赞0


评论


指令者指令者

  for(consteofworld.querySelectorAll('*')){//遍历每个实体e.enableDamage=true//允许这个实体受伤/喵/复活} functionspawnEntity(x,y,z,meshName){ constmeshScale=1/10//默认模型方块大小倍数为地图方块的1/16,看你实体的大小 returnworld.createEntity({ mesh:meshName,//模型名 collides:true,//能碰撞 fixed:false,//固定 gravity:false,//受重力影响 meshScale:[meshScale,meshScale,meshScale],//xyz放大倍数 position:[x,y,z],//位置坐标 }) }world.onPress(({button,entity,raycast})=>{if(button==='action0'){//判断是否按了左键(action1是右键)console.log(`${entity.player.name}按下了左键`);varball=spawnEntity(entity.position.x+raycast.direction.x,entity.position.y+raycast.direction.y,entity.position.z+raycast.direction.z,"mesh/火球.vb");//发射模型的名称ball.velocity.x+=raycast.direction.x*3;ball.velocity.y+=raycast.direction.y*3;ball.velocity.z+=raycast.direction.z*3;//把乘数放大可以让实体飞得更快!注意xyz放大的数都要一样!!!}})

点赞0


评论


浮生awa浮生awa

这么好的帖,怎么能不挖!

点赞2


评论


果果1~果果1~

world.onPress(({ button, entity, raycast }) => {        if(button ==='action0'){           console.log(` ${entity.player.name} 按下了左键`);           var ball = spawnEntity(entity.position.x+raycast.direction.x, entity.position.y+raycast.direction.y,                                        entity.position.z+raycast.direction.z,"mesh/火球.vb");           ball.velocity.x += raycast.direction.x*3;           ball.velocity.y += raycast.direction.y*3;           ball.velocity.z += raycast.direction.z*3;        } })     

点赞0


评论


霜雾霜雾

emm

点赞0


评论


薹灣解放再改名薹灣解放再改名

for(consteofworld.querySelectorAll('*')){//遍历每个实体e.enableDamage=true//允许这个实体受伤/喵/复活} functionspawnEntity(x,y,z,meshName){ constmeshScale=1/10//默认模型方块大小倍数为地图方块的1/16,看你实体的大小 returnworld.createEntity({ mesh:meshName,//模型名 collides:true,//能碰撞 fixed:false,//固定 gravity:false,//受重力影响 meshScale:[meshScale,meshScale,meshScale],//xyz放大倍数 position:[x,y,z],//位置坐标 }) }world.onPress(({button,entity,raycast})=>{if(button==='action0'){//判断是否按了左键(action1是右键)console.log(`${entity.player.name}按下了左键`);varball=spawnEntity(entity.position.x+raycast.direction.x,entity.position.y+raycast.direction.y,entity.position.z+raycast.direction.z,"mesh/火球.vb");//发射模型的名称ball.velocity.x+=raycast.direction.x*3;ball.velocity.y+=raycast.direction.y*3;ball.velocity.z+=raycast.direction.z*3;//把乘数放大可以让实体飞得更快!注意xyz放大的数都要一样!!!}})

点赞0


评论


全能代码师全能代码师

挺不错但是格式…还有用矢量很简单imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"

点赞1


评论


凌_墨水凌_墨水

你的排版被吃了emotion_doge

点赞1


评论


究极石头究极石头

center_imagecenter_image

点赞0


评论


功名功名

  for (const e of world.querySelectorAll('*')) { //遍历每个实体 e.enableDamage = true //允许这个实体 受伤/喵/复活 }     function spawnEntity(x,y,z,meshName){     const meshScale = 1/10 //默认模型方块大小倍数为地图方块的1/16,看你实体的大小     return world.createEntity({       mesh:meshName,//模型名       collides:true,//能碰撞       fixed:false,//固定       gravity:false,//受重力影响       meshScale:[meshScale,meshScale,meshScale],//xyz放大倍数       position:[x,y,z],//位置坐标     })   }    world.onPress(({ button, entity, raycast }) => {     if(button ==='action0'){//判断是否按了左键(action1是右键) console.log(` ${entity.player.name} 按下了左键`); var ball = spawnEntity(entity.position.x+raycast.direction.x, entity.position.y+raycast.direction.y, entity.position.z+raycast.direction.z,"mesh/火球.vb");//发射模型的名称 ball.velocity.x += raycast.direction.x*3; ball.velocity.y += raycast.direction.y*3; ball.velocity.z += raycast.direction.z*3;//把乘数放大可以让实体飞得更快!注意xyz放大的数都要一样!!! }  })  }

点赞0


评论


功名功名

  for (const e of world.querySelectorAll('*')) { //遍历每个实体 e.enableDamage = true //允许这个实体 受伤/喵/复活 }     function spawnEntity(x,y,z,meshName){     const meshScale = 1/10 //默认模型方块大小倍数为地图方块的1/16,看你实体的大小     return world.createEntity({       mesh:meshName,//模型名       collides:true,//能碰撞       fixed:false,//固定       gravity:false,//受重力影响       meshScale:[meshScale,meshScale,meshScale],//xyz放大倍数       position:[x,y,z],//位置坐标     })   }    world.onPress(({ button, entity, raycast }) => {     if(button ==='action0'){//判断是否按了左键(action1是右键) console.log(` ${entity.player.name} 按下了左键`); var ball = spawnEntity(entity.position.x+raycast.direction.x, entity.position.y+raycast.direction.y, entity.position.z+raycast.direction.z,"mesh/火球.vb");//发射模型的名称 ball.velocity.x += raycast.direction.x*3; ball.velocity.y += raycast.direction.y*3; ball.velocity.z += raycast.direction.z*3;//把乘数放大可以让实体飞得更快!注意xyz放大的数都要一样!!! }  })  }

点赞0


评论


雪球_r-L雪球_r-L

谢谢,成功了emotion_goodemotion_good

点赞0


评论


BOSS不爱吃鱼的小鱼BOSS不爱吃鱼的小鱼

world.onPress(({ button, entity, raycast }) => {        if(button ==='action0'){           console.log(` ${entity.player.name} 按下了左键`);           var ball = spawnEntity(entity.position.x+raycast.direction.x, entity.position.y+raycast.direction.y,                                        entity.position.z+raycast.direction.z,"mesh/火球.vb");           ball.velocity.x += raycast.direction.x*3;           ball.velocity.y += raycast.direction.y*3;           ball.velocity.z += raycast.direction.z*3;        } })

点赞0


评论