Onimpact forcedirection not accurate?

JohnG

Member
I am testing this by drawing a line using the OnImpact position and OnImpact forceDirection. I was thinking that this line should follow along the barrel of the weapon to the theoretical start position of the bullet. This is not lining up on my tests, am I correct in my thinking?
 
Using a hitscan weapon the direction is the vector that you are referring to, but for a projectile it is the normalized velocity.
 
Using a hitscan weapon the direction is the vector that you are referring to, but for a projectile it is the normalized velocity.

Let me rephrase the statement/questions. I am using hitscan, I am drawing a debug line from the impact position of the hitscan, in the forceDirection. The debug line is not lining up with the gun (in aim mode). Is this correct or should the debug line I draw be accurate (i.e. line up along barrel of gun, through point of impact, along forcedirection).
 
Last edited:
With a hitscan fire type the direction will be in the direction of the hitscan raycast. You could draw a debug line to see that by outputting the fireDirection within ShootableWeapon.HitscanFire.
 
With a hitscan fire type the direction will be in the direction of the hitscan raycast. You could draw a debug line to see that by outputting the fireDirection within ShootableWeapon.HitscanFire.

I think I have found the problem, however I am not sure how I got here or how to fix it.

The debug line aligns perfectly to the first person weapon, however I am in third person mode, so my hitscan line does not align with my characters weapon. What do I need to do in order to align the hitscan with third person mode?
 
Third person mode is a bit different because the ray isn't being fired directly in the center of the camera. The weapon is always going to be fired towards the crosshairs, and with the third person camera offset that direction will have a slight offset in order to compensate for this.
 
Third person mode is a bit different because the ray isn't being fired directly in the center of the camera. The weapon is always going to be fired towards the crosshairs, and with the third person camera offset that direction will have a slight offset in order to compensate for this.

Putting this here so that it possibly helps someone else....

I found a inspector variable that is probably designed to aim down the weapon. It is the "fire in look source direction" inspector variable. If you draw a debug ray, it will move exactly through the length of the weapon. The only other thing I needed to do is alter the x and y rotation of the weapon (in character structure) so that it lines up with the impact position on the target.

Tested with shotgun and pistol, so far so good.
 
Putting this here so that it possibly helps someone else....

I found a inspector variable that is probably designed to aim down the weapon. It is the "fire in look source direction" inspector variable. If you draw a debug ray, it will move exactly through the length of the weapon. The only other thing I needed to do is alter the x and y rotation of the weapon (in character structure) so that it lines up with the impact position on the target.

Tested with shotgun and pistol, so far so good.

Ignore! Still not accurate. The above is dependent on distance to object hit. Still frustrated.
 
Top