Firing in wrong location

Maximuz24

Member
I have a rifle with scope attached. When fire without aiming it firing correctly but when i aim and fire(scope active) its raycast hit is wrong(offset).

I have followed steps till 3 step in scope section of shootable weapon .l didnt add any render texture. If ray cast hit at correct location then it will be fine please help.
1571417259701.png

1571417479601.png
 
Please post these type of questions within the Questions forum.

The best way to debug this is to place a breakpoint within ShootableWeapon.HitscanFire and see where the firePoint/fireDirection is located. This will allow you to determine what variable is pointing in the correct direction.
 
Please post these type of questions within the Questions forum. Noted

The best way to debug this is to place a breakpoint within ShootableWeapon.HitscanFire and see where the firePoint/fireDirection is located. This will allow you to determine what variable is pointing in the correct direction.
Please tell me how to do that.
 
This is a pretty good video:


Breakpoints are an excellent debugging tool and once you learn how to use them they make understanding what is going on so much easier.
 
This is a pretty good video:


Breakpoints are an excellent debugging tool and once you learn how to use them they make understanding what is going on so much easier.

Thanks, and please let me know which value i need to take and where to apply these values. is it on weapon transformation.

1572202995534.png
 
Your fire direction is Vector3.zero - keep stepping to see what value is set. Also, you'll want to continue to step to see what object the raycast did it. You can insert Debug.DrawRay statements in order to visualize where it is firing.
 
Thanks Justin, but when i check in FPS that when i aim the Rifle is moving to the center and aligns with the debug ray cast. which setting i need to adjust so that my player which is in third person view moves the rifle to the center i think this will solve my problem.
1573798825588.png
 
Third person view is always tricky for aiming because the crosshairs direction isn't the same as the camera direction as it is in first person view. I've added it to my list to be able to add an offset to the fire point so that you can make adjustments while you are aiming in third person view.
 
Third person view is always tricky for aiming because the crosshairs direction isn't the same as the camera direction as it is in first person view. I've added it to my list to be able to add an offset to the fire point so that you can make adjustments while you are aiming in third person view.
Thanks it will be there in next week update?
When i use non dominant Hand ik target the reload and detach clip will not work how i can correct that.
 
Last edited:
I am always hesitant towards adding new features this close to release so this will instead be included in the next update.
 
I am always hesitant towards adding new features this close to release so this will instead be included in the next update.
Do you have any other option for this mean any other solution? and i think it will take months after this update ?also When i use non dominant Hand ik target the reload and detach clip will not work how i can correct that.
 
Last edited:
@Maximuz24, put a Reload state on CharacterIK that turns the hand weight to 0.

@DankP3 Thanks A lot. do you have any solution for my 1st question in this .
I have a rifle with scope attached. When fire without aiming it firing correctly but when i aim and fire(scope active) its raycast hit is wrong(offset).

I have followed steps till 3 step in scope section of shootable weapon .l didnt add any render texture. If ray cast hit at correct location then it will be fine please help.
 
I don't have an ETA for the next update but will post when I make the changes. No changes are required for first person - in the demo scene you'll see that the assault rifle correctly fires at the scope location. The issue only relates to firing from a third person perspective.
 
I don't have an ETA for the next update but will post when I make the changes. No changes are required for first person - in the demo scene you'll see that the assault rifle correctly fires at the scope location. The issue only relates to firing from a third person perspective.
@Justin Any update on this. Thanks in advance.
 
I still have this one on my list. No ETA yet but I'll let you know when I am able to add it.
 
I still have this one on my list. No ETA yet but I'll let you know when I am able to add it.
I Think The aim ( fire point ) is from the ray cast from the player head correct? Is it possible to change that ray cast ( fire point )to scope camera center?
Thanks
 
In most cases the raycast is from the fire point. When the character is aiming you could create a script which adjusts this location of the fire point to be located at the scope (or you could always have it in this location, even when not aiming. This would prevent you from needing to script anything).
 
@Justin If I move the fire point to the middle of the scope camera is there any problem it can resolve the issue? First iamge shows fire point and second image shows scope camera. i want at the middle of the lens/point. If Ray cast is from firing point then it have to work correct?
1582819052563.png
1582819148194.png
 
If you move the fire point does it work as you'd expect? There's no problem with moving it to that location.
 
Top