
Lv.1
就让这一切从头开始吧
签名:离线中
在 【box3】机关喵效果代码! 中回复
发射实体子弹独家秘方,未经允许不得转载。
world.onPlayerJoin(({entity})=>{
entity.position.set(53,3,123);
entity.player.scale = 0.4;
entity.player.runSpeed = 0.2;
entity.player.walkSpeed = 0.12;
entity.player.jumpPower = 0.5;
entity.player.enableDoubleJump = false;
entity.enableDamage = true;
profession(entity);
entity.player.onPress(async({button,raycast:{hitPosition}})=>{
console.log(hitPosition);
if(button == 'action0'){
entity.player.enableShoot = true;
while(entity.player.enableShoot){
await sleep(200);
//raycast.
world.sound('audio/10828.mp3')
biu(entity,hitPosition);
}
}
})
entity.player.onRelease(({button})=>{
if(button == 'action0'){
entity.player.enableShoot = false;
}
})
})
async function biu(attacker, target){
bullet = world.createEntity({
mesh: 'mesh/球形炮弹.vb',
position: attacker.position,
collides: false,
fixed: true,
meshScale: new Box3Vector3(0.002,0.002,0.002),
meshOrientation: attacker.meshOrientation,
})
bullet.shooter = attacker;
bullet.addTag('bullet');
bullet.gravity = false;
bullet.Cx =0;
bullet.Cy =0;
bullet.Cz =0;
bullet.startPos = copy(attacker.position);
bullet.distance = 0;
bullet.speed = 2;
子弹实体化还原(200,bullet);
function init (A, B) {
var dx = B.x -A.x;
var dy = B.y -A.y;
var dz = B.z -A.z;
AB = Math.sqrt(dx*dx + dy*dy + dz*dz);
if (AB==0)
return;
bullet.Cx = dx /AB;
bullet.Cy = dy /AB;
bullet.Cz = dz /AB;
}
init(attacker.position, target);
bullet.onEntityContact(({other})=>{
other.hurt(5);
other.killer = bullet.shooter;
bullet.destroy();
})
}
function updatePos(bullet){
bullet.distance+=bullet.speed;
bullet.speed *=.99;
bullet.position = new Box3Vector3(
bullet.distance *bullet.Cx + bullet.startPos.x,
bullet.distance *bullet.Cy + bullet.startPos.y - bullet.distance*.01,
bullet.distance *bullet.Cz + bullet.startPos.z
)
if(voxels.getVoxel(bullet.position.x,bullet.position.y,bullet.position.z)!=voxels.id('air')){
bullet.destroy();
}
if(bullet.speed <0.2){
bullet.destroy();
return;
}
}
async function 子弹实体化还原(time,bullet){
await sleep(time);
bullet.collides = true;
}
world.onTick(()=>{
world.querySelectorAll('.bullet').forEach((bullet)=>{
updatePos(bullet);
})
})2020-08-26T22:25:32 点赞:13
在 【3.0求答】对话框的选项怎么弄,还能做到点一个就触发xxx的代码 中回复
const result = await entity/*也可以是其他主语*/.player.dialog({
type: Box3DialogType.SELECT,
title: "吉吉喵",
titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
content:'对话内容',
})
//你要执行的代码2020-09-23T19:35:52 点赞:0
在 【box3】MC复原计划! 中回复
其实,这也是有问题的,我的世界的地图超级大,而岛三活动范围可以为无限,所以我建议方块都用模型,地图大小问题。而且玩家存档的SQL很难。
2020-11-04T20:14:59 点赞:0
在 岛3中怎么设随机数和重复执行(永远重复) 中回复
随机数:
Math.random()这段代码可以返回0~1的小数,你可以把它当成一个数字用,如果要随整数,把代码带进去:
function intRandom(f,b){
return(f+Math.round(Math.random()*(b-f)))
}
使用的时候就写intRandom(随机数的最小值,随机数的最大值),还是可以直接当成数字用。
重复执行就是:
while(true){
//你要执行的代码
}
切记,执行后要等待一段时间,用await sleep(等待时间毫秒数)
1000毫秒=1秒
使用等待时必须异步执行,不然会报错:
Error:async is only villed in async function
使用异步执行可以
比如说:
world.onPlayerJoin(({entity})=>{})
异步执行后是:
world.onPlayerJoin(async({entity})=>{})
2020-11-12T18:33:22 点赞:0
在 【box3】地形定制小店! 中回复
https://box3.codemao.cn/e/a9喵450b7a3055bc346a
要一座高山脉,旁附一些小山,底下水,水边是沙子
2020-11-28T09:40:55 点赞:0
在 【岛3求助】如何像起床战争那样打入虚空对手加分? 中回复
//方法一
world.onPlayerJoin(({entity})=>{
world.onTick(()=>{
if(entity.position.y < -10){
//打入虚空了,你想作甚?
}
})
})
//方法二
const area = world.addTrigger({
selector: 'player',
bounds: {
lo: [-50,-50,-50],
hi: [305,-10,305],
},
})
area.onEnter(({entity})=>{
//进来了
})
2020-11-28T13:59:42 点赞:0