用户:
Nysidla查看:0 回复:8 评论:0 创建时间:2023-05-19T22:48:03
world.onPress(async ({ entity, raycast }) => {
let e = world.createEntity({
position: entity.position.add(new Box3Vector3(raycast.direction.x, raycast.direction.y, raycast.direction.z)),//生成位置
mesh: `mesh/投掷物名称.vb`,//投掷物名称
gravity: false,//取消下落
collides: true,//开启碰撞
meshScale: new Box3Vector3(0.05, 0.05, 0.05),//大小
meshOrientation: new Box3Quaternion(0,0,0,1).rotateY( Math.atan2( raycast.direction.z, raycast.direction.x)).rotateY(Math.PI / 2),
//按照MC那样,不考虑上下的旋转,我的模型是X X 1的,如果是1 X X的不用加第二个rotateY(应该吧我也没试过)
velocity: raycast.direction.mul(new Box3Vector3(2, 2, 2)),//设置velocity,mul里的数字随便搞,114514都可以()
fixed: false,//因为有velocity,所以要让实体能动起来
friction: 1.5,//也是,随便选,推荐1.2+,2-,这个期间的实体碰到东西后,会停止(或者向前滑行一段,大约1.4+(含1.4)会回弹一段())
})
})
当然,这只能平飞,还要加夏洛的网(划掉)()
world.onTick(async () => {
world.querySelectorAll('.XXX').forEach((entity) => {
entity.velocity.y -= 0.05//随便,但不要太高
if (entity.voxelContacts.length > 0) {//判断是不是碰过方块
entity.destroy()//摧毁
}
})
})
//用setInterval也行()
OK,本期教程就到这里了,886()()()())()(
希望评论多点()
const pl = world.querySelectorAll('player').find(e => e.player.name == entity.zhu) pl.position = new Box3Vector3(entity.voxelContacts[0].x, entity.voxelContacts[0].y + 2, entity.voxelContacts[0].z) 末影珍珠 去了onTick就是火焰弹了()()()()()()()()
点赞0
评论
加上我之前的背包代码:
world.onPress(async ({ entity, raycast }) => {
let e = world.createEntity({
position: entity.position.add(new Box3Vector3(raycast.direction.x, raycast.direction.y, raycast.direction.z)),//生成位置
mesh: `mesh/投掷物名称.vb`,//投掷物名称
gravity: false,//取消下落
collides: true,//开启碰撞
meshScale: new Box3Vector3(0.05, 0.05, 0.05),//大小
meshOrientation: new Box3Quaternion(0,0,0,1).rotateY( Math.atan2( raycast.direction.z, raycast.direction.x)).rotateY(Math.PI / 2),
//按照MC那样,不考虑上下的旋转,我的模型是X X 1的,如果是1 X X的不用加第二个rotateY(应该吧我也没试过)
velocity: raycast.direction.mul(new Box3Vector3(2, 2, 2)),//设置velocity,mul里的数字随便搞,114514都可以()
fixed: false,//因为有velocity,所以要让实体能动起来
friction: 1.5,//也是,随便选,推荐1.2+,2-,这个期间的实体碰到东西后,会停止(或者向前滑行一段,大约1.4+(含1.4)会回弹一段())
})
findNum(entity,1)
})
function findNum(entity, type) {
if (type == 1) {
if (entity.setUp.onhand[0].slice(entity.setUp.onhand[0].indexOf('*') + 1) == 1) {
entity.setUp.bar[entity.setUp.onhand[1]] = '空'
entity.setUp.onhand[0] = '空'
} else {
let bar = entity.setUp.bar[entity.setUp.onhand[1]]
entity.setUp.bar[entity.setUp.onhand[1]] = bar.slice(0, bar.indexOf('*') + 1) + (Number(bar.slice(bar.indexOf('*') + 1)) - 1)
entity.setUp.onhand[0] = entity.setUp.bar[entity.setUp.onhand[1]]
}
}
//什么?不知道我之前做的什么?https://shequ.codemao.cn/community/539206
}点赞1
评论