Rotate mesh towards Toss velocity

Hello, I am having a bit of a problem understanding how to rotate mesh towards toss Velocity. I have a mesh with a socket that points to a target.

I have used SuggestProjectileVelocity to find out the toss velocity which is coming out to be fine as in the image.

Now the problem is at what angle should I rotate as the toss velocity is coming from the socket location but I want to turn my mesh whose pivot point would be different from the socket location. Like what would be theta1

I hope I am able to explain my problem. Thank you

Hey @FinalRockstar, so if I’m understanding the problem correctly, you’re pathing the arc from the projectile socket but want to rotate the gun itself and not a projectile of it, and you just want the gun itself to rotate towards it’s current velocity?

I myself have only ever used the projectile component since it has this functionality built in, however there’s more custom approaches to this. I came across a thread that does just a basic turn object to it’s velocity but I feel like I’m missing something with the casting from the projectile shooting socket.

Let me know if I’m off base, a clarification might get me sorted!


Hi Yes you understood the problem correctly . I want to rotate my mesh towards the toss velocity. But I have a question . I have calculated Toss velocity from socket so if I normalize and find the direction from socket then the direction which is pointing at, will it be same for mesh also ? So I just need to use find look at Rotation function where start would be mesh location and target would be the normalized toss velocity? Or do I need to apply some more calculations? I will also try with projectile component if I am unable to solve. Thanks for the info

1 Like

Hi there,
If you want both shots to match the target location, you may want to try this node:

Start Pos will be different for each actor, but End Pos will be the same.
Then, you can use find look at rotation to rotate your mesh towards the target position with Set Actor Rotation

1 Like

If you are working from that socket specifically I think you’d have to do an arc from the gun’s pivot/center of mass and use that instead as unless you’re prepping the arc for the projectiles themselves instead. You could do this from a different socket, the sm itself, or you’d have to overlay some more math over the arc from the projectile socket, but that’d be more complex than just doing the arc with the gun itself

1 Like

Hi thank you for reply so I want to ask what is the difference between both these functions other than custom arc has fixed arc of 45 degree. Also I have only one actor to shoot which is having a socket (not multiple actors) . I am using suggest velocity from socket and if I use the result from that and rotate actor from center of mass then won’t it be wrong ?

If I use suggest velocity from center of mass of mesh then won’t the projectile overshoot the target? And if the center of mass is way back then the result could be very far ?

You can use the socket location instead. The start pos is the actual spawning point. Then use the suggested velocity to set your projectile initial velocity right after spawn actor (projectile) from class.

Arc Param = 0.5 is about 45Âş degrees

I guess you should calculate the find look at rotation for aligning the canon angle, then calculate spawn velocity with the suggested node. From what I could see, the canon is only a component of the tank, correct? In this case, you can use control rig or “skeleton control” transform modify bone to rotate in world space.

1 Like

Yes so I will use the socket location to find toss velocity and will set the initial velocity of projectile to the suggested velocity that part is clear, I am more concerned with the alignment of cannon at a correct angle.
“I guess you should calculate the find look at Rotation for aligning the cannon angle” - so the target would be the toss velocity from suggest velocity function which used socket’s location as start position? Will that be correct ? I will need to check it.
Yes it’s a part of component of a tank but it doesn’t have any skeleton.

Yes, you can you the node “find look at rotation” to set the cannon rotation in world space. If the canon is a child actor of the tank, it will be easier to get its actor rotation. The start pos for the cannon should be the canon’s pivot point. The end pos is the target. Also, the start pos for the shot is the socket location, and the Pitch Y Axis angle should be 45º. So, the only angle missing is the Yaw ZAxis taken from find look at rotation.

First you align the cannon to the target, then calculate the shot velocity and spawn the projectile from the socket location. The projectile velocity is set by the suggested velocity after spawn actor from class.

I hope that makes sense. I’ll check up on you tomorrow.

1 Like

Thank you for taking the time out. I will come up with the update as soon as possible

Looking forward to seeing if works.

Hello, So I have tried to use Socket as well as Mesh as the start Position. Here is my observation

Using Mesh As Start Position


Blueprint Setup

Using Socket As Start Position


Blueprint Setup

I have changed My mesh to be a very long box. I did this to figure out any issues easily as with the Gun it was shooting target correctly because the difference between socket position and gun center of mass position was not enough.

And Shooter Actor is a simple one that just rotates

As you can see in both the setup the shooter actor is able to turn correctly but the problem is for Pitch as in one it overshoots and in the other it undershoots.

Hi there,
Thank you for sharing the logic, that helps to understand what is causing the issue.
You’re almost there. I believe you’ve missed that “find look at rotation”:

If you’re changing the cannon’s pitch, this information should be feeding into the projectile calculation, however only the node “Suggest Projectile Velocity with Custom Arc” has such parameter exposed in Blueprint. Keep in mind that the cannon’s pitch of 0 - 90º equals to 1 - 0 in that node (“Arc Param”). So, you’ll need a “map range clamped” node.

In my timelapse video, I show how to use that node with a projectile launch at time 1:03

Hope that helps.

1 Like

Thank you for taking out time to answer. If I use ActorToPoint’s Location in FindLookAtRotation then the Shooter Actor or Cannon will directly point to Target instead of slight inclination. Although by setting velocity the projectile hits the right target. This inclination problem may or may not be noticeable. As of now, I am happy with the solution you provided : )

As for “Suggest Projectile Velocity with Custom Arc” what is the difference between Out Launch Velocity and Toss Velocity of “Suggest Projectile Velocity"? I am sorry for asking too many questions.

1 Like

Hi there,
Glad it helped you. The velocities are the same, the different is that you have more inputs to control your trajectory with Suggest Project Velocity with Custom Arc. Also, I believe Out Launch Velocity is a direct reference to the input used in the node Lauch Character.

Keep up the good work.

1 Like

Thank you :slight_smile: