I make a turret, who aims it’s head at character. The new problem I have is turning a bullet.
When it spawns, it gets impulse and flies away, but don’t rotate. I want to make it rotate with cone’s nose parallel it’s moving like real. Thanks!
You can use “Find Look At Rotation” to rotate the bullet, giving the vector values:
- Spawn location of bullet
- Location of target
Setting this once will give you a fixed rotation that won’t change, so it assumes your bullet does not have physics rotation that will change it. You can also update this rotation per frame if you wish to, which involves changing the first vector value to the current bullet location, which updates. This means the rotation will be pointing toward the target location at all times, even if the target moves.
You can also use the VELOCITY (Get Velocity / Get Component Velocity) of your bullet to determine which direction it should face. Using “Find Look at Rotation”, first value as your bullet location, and second value as the bullet location + velocity. You can either make sure that this rotation happens after the bullet receives an impulse (and has already a velocity higher than zero) or call it every frame (reducing performance).
Give the bullet actor a “rotational movement” component and set the rotation of the “X” axis (roll) to whatever speed you would like. This way when the bullet is spawned it will rotate around the forward vector axis like a real bullet.
If I use velocity, then bullet flies in 90° rotation against trajectory and when collides the floor starts histerics:).