“启动投射物问题”

huangapple 未分类评论44阅读模式
标题翻译

Minecraft Plugin launchProjectiles Question

问题

我想用launchProjectile编写自己的武器系统,我正在使用箭头。但是在不增加散射的情况下,如何增加箭头的速度。以下是代码:

@Override
public void shootEffects(Player player) {
    Arrow projectile = player.launchProjectile(Arrow.class);
    projectile.setVelocity(projectile.getVelocity().multiply(1));
}
英文翻译

I wanted to code my own Weapon System with launchProjectile and im using an Arrow. But how can I increase the Arrow speed while don´t increasing the Spread. Heres the Code:

@Override
public void shootEffects(Player player) {
	Arrow projectile = player.launchProjectile(Arrow.class);
	projectile.setVelocity(projectile.getVelocity().multiply(1));
	
}

答案1

得分: 0

问题并不是非常清楚,但我认为您想要的是以高速行进的100%准确的箭。

如果是这样,这就是为您准备的 “启动投射物问题”

@Override
public void shootEffects(Player player) {
    Arrow projectile = player.launchProjectile(Arrow.class);
    projectile.setVelocity(player.getEyeLocation().getDirection().multiply(HIGH_NUMBER));
}

在这里,我们获取玩家所看方向的向量,并将该向量乘以一个数以增加速度。

英文翻译

The question isn't very clear but I think what you want is a 100% accurate arrow travelling at high speed.

If so, this is for you “启动投射物问题”

@Override
public void shootEffects(Player player) {
    Arrow projectile = player.launchProjectile(Arrow.class);
    projectile.setVelocity(e.getPlayer().getEyeLocation().getDirection().multiply(HIGH_NUMBER));
}

Here we are taking the direction the player is looking in, getting it as a vector and multiplying the vector to increase the speed.

huangapple
  • 本文由 发表于 2020年3月17日 01:03:01
  • 转载请务必保留本文链接:https://java.coder-hub.com/60710176.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定