I want my turret to fire in any direction. At first, it aims character, than gets permission and spawns a bullet, which has an impulse in own blueprint. Please help me to teach the bullet to fly in correct direction. Thanks!!!
Hey try looking here for a simple FPS tutorial How to Create a Simple FPS in Unreal Engine 4 | raywenderlich.com
The idea behind shooting turret is the same as shooting gun in FPS. Only difference is that you first need to detect whatever you wanna shoot at, then rotate your turret to face the target (for example use Find Look at Rotation) and then shoot.
Hope it helps
Thank you very much, but it is not what i actually need. There is example with linrtrace.
I can spawn a bullet in corrrct place and rotation, but not to make it fly in correct direction
Here is a tutorial I made that walks you through how to shoot a moving player. Is this more what you are looking for?
I think all you need then is just to give the bullet a correct velocity to jumpstart it.
- Attach UProjectileMovementComponent to the bullet (UProjectileMovementComponent | Unreal Engine Documentation ), this will allow you to use physics.
- Set projectile velocity on UProjectileMovementComponent by using SetVelocityInLocalSpace method
- Activate the UProjectileMovementComponent using Activate method, this should fire the bullet
Using UProjectileMovementComponent allows physics engine to take care of the bullet movement, if you are rotated in direction of your target use Forward Vector * BulletSpeed, to set the correct velocity. Hope this is what you needed.