I’m taking my first baby steps with UE4 (and programming in general) and was wondering if anyone could help me with this. I’m using the shooter example tutorial and I’d like to mess with the weapons a little more and add real recoil instead of the viewshake effect. As in I want the view to kick up and perhaps sideways a little bit every time a bullet is fired but never down like with the viewshake effect. Anyone know how to do this or if there’s a tutorial for it?
you can get ideas here
http://udn.epicgames.com/Three/UsingSkeletalControllers.html#Recoil
This SkelControl simulates the force applied to arms when a weapon is fired. While the same effect could be done using animations, the advantage of using this SkelController is that it allows you to pair it with other SkelControls. Often with this node, you will only want it to affect a single bone, in this case the b_IK_Gun. SkelControlLimb is then used on the left and right hand bones to perform inverse kinematics on the hand bones attached to b_IK_Gun.
and here you can learn about pysical animations in unreal 4.
https://docs.unrealengine.com/latest/INT/Resources/ContentExamples/Animation/index.html#physicalanimationmap
Hi, thank you for your post. I think you misunderstood what I’m looking for however. I’m trying to figure out how to create recoil as a gameplay element. As in when you fire the gun, your crosshair along with your view kicks up. The player would have to aim lower again for the next bullet to hit his target. The visuals for hands and weapon model are the step after that.
I looked at the source a bit and I think I spotted a weapon constructor where you have values for spread, rate of fire, damage etc. etc. How would I add recoil there?
aaa, I think that you looking for some very bizarre and avanced system.
Imo, You only need set a offset in the camera.
I came up with a really simple recoil blueprint.
Just create a variable (float) to hold the amount of recoil you want then attach it to the ‘Add Controller Pitch Input’ function when your weapon fires.
This was done in the FPS Blueprint template.
That works, thank you. Do you have any idea how I could make the viewkick slower as opposed to being instant?
Is there any thing else you have to do to make this work? like setting values or anything outside of the float?
Use a timeline and a LERP between the current value and the recoil value that you want.
Using a float is the easiest way to set recoil (using [random float in range] adds some neat randomization).
Edit]
Here is a basic recoil Blueprint that is simple enough for recoil affecting both pitch and yaw
I’m sure there are ways to do this better, or to simplify (cleanup) but it works pretty well for me as a basic system.
(Please keep in mind these were rough blueprints used to achieve a quick result during testing - )