Author Topic: Adding velocity to a player when hit by a projectile  (Read 1564 times)

so essentially when a player object gets hit by a projectile they gain velocity in the same direction as which the projectile hits them

kinda like knockback on the target

i've tried using axis and getting vectors and stuff but none of it seems to work. Does anyone know how to do this?

Is adding impactImpulse = 1000; and verticalImpulse = 1000; to the ProjectileData not good enough?

Is adding impactImpulse = 1000; and verticalImpulse = 1000; to the ProjectileData not good enough?
hnnng i'm a loving idiot

For some reason, impactImpulse is ignored in my weapon. No matter what value i set it to, the target stays completely still.

Is adding impactImpulse = 1000; and verticalImpulse = 1000; to the ProjectileData not good enough?
As an aside, whenever you're working with impulses, I find it helps to write the value as 90 * (whatever velocity you want). 90 is the mass of the default player, and impulses are basically velocities scaled by the mass of whatever you're applying it to. So you can just use impactImpulse = 90 * 11.11; as an equivalent to 1000, and you'll be able to view and adjust it in terms of the velocity it will apply to a standard player.

For some reason, impactImpulse is ignored in my weapon. No matter what value i set it to, the target stays completely still.
Post the code.

Post the code.
I actually found the reason why. Apparently Item_Shield has a function that completely overwrites ProjectileData::impactImpulse, so I'm going to try and disable that and see if it makes a difference

impactImpulse is the horizontal impulse, without any vertical impulse, the player won't really go anywhere because they stick to the floor

There is something loving up the entire ImpactImpulse value server-wide. I can't pin it to anything. My best bet rn is to replicate it using applyImpuse. The issue: I need a vector in order to work it through.

Is there any way to get the vector in which a projectile impacts a player and the direction the projectile was traveling? If someone can answer that at least I will be able to fix my issue.

There is something loving up the entire ImpactImpulse value server-wide. I can't pin it to anything. My best bet rn is to replicate it using applyImpuse. The issue: I need a vector in order to work it through.

Is there any way to get the vector in which a projectile impacts a player and the direction the projectile was traveling? If someone can answer that at least I will be able to fix my issue.
If you've set up the impactImpulse correctly, then this specific weapon isn't your issue. Working around it's just gonna make a mess. Either use trace to see exactly what's going on when you shoot something, or disable all other add-ons then re-enable them 10 at a time until you find out the cause.

you only need to work around it if you want the impulse to work differently than directly in the opposite direction of explosion.

you only need to work around it if you want the impulse to work differently than directly in the opposite direction of explosion.
The point is that I want impactImpulse to work. Right now, impactImpulse is never being registered by any projectile, which just causes players to fly up instead of in horizontal directions. This is applied to push broom, gun, guns akimbo, etc. Only on projectiles.

I've disabled every add-on and it still persists.

oh, its that bug. its just impulsing you up, correct?

i have a similar issue on my server so i'll take a look into it when i get back home.

oh, its that bug. its just impulsing you up, correct?
Yeah exactly

Try posting the explosion/projectile code