Change Initial Rotation Based on Toss Velocity

What sort of rotation are you looking for?

My only suggestion with the information provided is to try changing world rotation with local rotation, there is a function called add local rotation, which you could try.

I have an AI turret It has fixed Launch Spped and end location. Is it possible to calculate Start Location using SuggestprojectileVelocity.I have tried the following thing but it rotates wrongly.

I am looking for Pitch

I more meant what is rotating and how you want it to rotate.

So a Sphere fired from the gun can rotate on its own axis like the earth spinning, that is its local rotation. However the earth also rotates around the sun, that is world rotation.

If you are doing the moon and Earth, Earth needs to spin on local X, the moon needs to spin on local X to spin but will then also need to rotate on world X,Z to go around the Earth.

So you say you have a Turret and a launch speed, end location…ETC but what is the effect you are looking for?

It the turret moving based on the shot, so are you trying to emulate recoil? So as the gun fires the turret tilts?

Are you looking for the turret to turn to face things?

Do you want the actor to move within the world based on the velocity of fire?

Is it the object the turret shoots that you want to rotate?

This will determine whether you need local or world rotation.

If you are emulating recoil → local rotation will be require (you will also need to have the correct anchor point I.E where the turret rotates, you most likely would have a separate barrel for this)

If you want the entire gun to flip or something, you would need world rotation.

Hi sorry for the confusing Post. Basically what I want is like the target position is fixed and launch speed will also be fixed for the projectile and so using that I want my Turret to adjust its elevation in world space so that the projectile hit the desired location.

I’m still not sure I understand, what it is you want to do, however;

Maybe this will help? (skip passed the C++ code bit)


Looking at your original code, you are using a find look at rotation which takes in a start and target location. You are feeding essentially your normalised velocity in to the target. (not a location)

Reading the tool tip “find look at rotation” is designed to point at a target. The target data you will be feeding in to the target node, where it needs to point to is something like X=0.3, Y=0.3, Z=5000.00 as that is the velocity you set. So you are not pointing to where your target is, you’re telling it to rotate and point at the velocity output…this is not where the target is but the force which you have applied to a projectile.

So you will be feeding something like:

X Roll -135
Y Pitch 89
Z Yaw 44

In to your world rotation, so I can only imagine it does some odd stuff. Your turret is now trying to turn in 3 different directions within the world.

You may well need to use a little more complicated mathematics to work out Velocity + Angle = distance. Or Distance / Velocity = angle? Something like that?

oh ok I will get back with the results. Thanks for the answer

Best of luck, been some years since my advanced mathematics classes, but it will be some sort of trigonometry function I would have thought.

Might depend on if you are applying gravity to the object, how much it affects the object, if the object you are firing has mass, what that mass is.

If you created a velocity of 5000 and apply to a 10kg object, it will react differently to a 2kg object.

If you are going for a realistic cannon fire look, mortar fire look. Then yeah sadly it is going to require some calculations on your side. I don’t know of any easy way to do this.

Other than that do scan fire / line trace shooting, ala COD4, points, shoots, if trace hits object, object dead.

I ended up using the following approach.

Excellent, I am glad you were able to find a solution, hopefully it is giving you the result you wanted. All the best with the project.