星耀☭
本帖最后由 112709347 于 2020-2-10 13:13 编辑

新人发帖

有些人会使用tp来制作追踪弹
我今天给大家带来一个不同的
     原理就是把目标的坐标和子弹的坐标相减,然后将值带入子弹
的Motion标签中



首先我们新建7个计分板,用来记录子弹的坐标和子弹将要达到的坐标
(/scoreboard objectives add 计分板名称 dummy)
我创建的是这7个
X0,Y0,Z0,X1,Y1,Z1,time

然后就可以进行运算和代入
指令如下:
红组命令方块(记录实体的位置)
由于计分板分数不能为小数,我们这里乘100保留两位小数
没乘100的话可能在目标和子弹的距离太小时计分板会四舍五入
为0导致子弹停止追踪
/execute as @e store result score @s X0 run data get entity @s Pos[0] 100
/execute as @e store result score @s Y0 run data get entity @s Pos[1] 100

/execute as @e store result score @s Z0 run data get entity @s Pos[2] 100

黄组命令方块(让子弹的将要达到的坐标=目标的坐标)
我这里设定的是雪球为子弹,tag=1的实体为目标
/scoreboard players operation @e[type=minecraft:snowball] X1 = @e[tag=1] X0
/scoreboard players operation @e[type=minecraft:snowball] Y1 = @e[tag=1] Y0
/scoreboard players operation @e[type=minecraft:snowball] Z1 = @e[tag=1] Z0

蓝组命令方块(把子弹将要达到的坐标和子弹的坐标相减)
/scoreboard players operation @e[type=minecraft:snowball] X1 -= @e[type=minecraft:snowball] X0
/scoreboard players operation @e[type=minecraft:snowball] Y1 -= @e[type=minecraft:snowball] Y0
/scoreboard players operation @e[type=minecraft:snowball] Z1 -= @e[type=minecraft:snowball] Z0
绿组命令方块(将相减的值带入子弹的Motion)
注意:指令中0.0035这个值会影响子弹的速度,由于前面把值乘了100我们现在再把它乘回去(execute前面的“/”自己脑补)
execute as @e[type=snowball] store result entity @s Motion[0] double 0.0035 run scoreboard players get @s X1
execute as @e[type=snowball] store result entity @s Motion[1] double 0.0035 run scoreboard players get @s Y1
execute as @e[type=snowball] store result entity @s Motion[2] double 0.0035 run scoreboard players get @s Z1
然后最左边的那两个命令方块是防止子弹一直卡着不消失造成游戏卡顿(不过一般来说是不会卡的)
/scoreboard players add @e[type=minecraft:snowball] time 1
/kill @e[scores={time=20..},type=minecraft:snowball]
然后这样就完成啦!

可以看到我生成了一个tag=1的受害者,虽然我是朝另一侧扔雪球的,但是雪球还是直直飞向了受害者
最后。。。啪叽!
大家也可以把子弹的速度调小,然后你会发现子弹的判定很精准



星耀☭
本帖最后由 112709347 于 2020-2-10 13:14 编辑

我这边不知道咋回事图片卡没了

然后我重新编辑了一下,顺便解决了子弹会卡住的BUG

天零12138
加油,(~ ̄▽ ̄)~

(=°ω°)丿
看到自动追踪,我想到的第一个是 潜影贝的导弹

星耀☭
隐退 发表于 2020-2-10 07:21
看到自动追踪,我想到的第一个是 潜影贝的导弹

我也是这样想的,好像还可以把潜影贝那个L和M的标签改成目标的L和M

安齐升
也可以在坐标0 0 0 生成朝向实体 ,将POS标签值复制到Motion行

第一页 上一页 下一页 最后一页