#vectors help
1 messages · Page 1 of 1 (latest)
Kb?
like make it apply a vector that is like the same as the explosion knockback, but with more knockback
so when it explodes, in entitydamagebyentityevent, i can have it apply that vector when they get hit by the explosion
Oh
but idk how to trace the vector from the fireball to the player
Get the direction of the player to the explosion center, reverse it, multiply it by something like 5 (you will have to test and figure out what value you want), and then set the player's velocity to that vector
the value im using config for but ye
If your asking how to get the direction do Location1#subtract(Location2).toVector()
k
ik this is gonna sound dumb, but what do i put for #subtract
xD
like it says theres no method
lol
but whats the subtract method
its not finding anything
for spigot
do i have to make a subtract method or smth
Oh it's location.getDirection.subtract
o
thx
so Vector velocity = event.getEntity().getLocation().getDirection().subtract(event.getDamager().getLocation().toVector());
Instead of reversing it just do explosionLocation.subtract(playerLocation)
But yes
oh
lol
What event are you using?
EntityDamageByEntityEvent
Oh nvm thats right
You shouldn't need to normalize it
oh
But if you want to then normalize after
Not for a velocity
it doesnt seem to work
@hearty grotto
it does a little more kb, but only shoots straight down when i shoot it under me
Could you send your code?
@hearty grotto it still seems to keep being weird
if im running and i use it, sometimes itll stop my momentum and pul me back a little
Try adding the velocity instead of setting it
so event.getEntity().setVelocity(velocity.normalize().add(event.getEntity().getVelocity()).normalize());?
works a lot better, but still pulls me towards it if the explosion is a little further away
btw another small issue, theres quite a bit of delay between clicking and it spawning, any idea why?
@EventHandler
public void onClick(PlayerInteractEvent event) {
if (event.hasItem()) {
if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
if (event.getItem().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(plugin, "fireball"), PersistentDataType.INTEGER)) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
event.setCancelled(true);
}
Fireball fb = event.getPlayer().launchProjectile(Fireball.class);
fb.setYield(plugin.getConfig().getInt("explosionpower"));
fb.setShooter(event.getPlayer());
if (event.getPlayer().getGameMode() == GameMode.ADVENTURE || event.getPlayer().getGameMode() == GameMode.SURVIVAL) {
event.getItem().setAmount(event.getItem().getAmount() - 1);
}
}
}
}
}
oh wait i think ik
my config didnt add the new default lol
for knockback
@hearty grotto
lol srry i keep pinging
So what is wrong with it?
still not applying forces right
@hearty grotto
like how does it work in stuff like hypixel
Ok I'll test it when I get home
with mine it keeps pulling me towards the fireball sometimes
but like if im running and then throw it i get launched
also for this theres like a whole second of delay after clicking
Give me like 30m and I'll see what I can do
@hearty grotto got an answer lol
?
lol
e
Oh sorry I was busy
xD
Well dm me if you want more help