Download

Rotate Vector around location

Hello community.

I’m trying to achieve behavior where line trace start position would be altered from the player pawn position by rotating it around the target sphere actors origin maintaining the distance between the two (look at the attached images). Amount of rotation is read from mouse X&Y movement and X value (Range: -1.0 to 1.0) would rotate the vector position left/right in relative to the sphere origin (red axis on the attached images), Y value down/up (green axis on the attached images). Both the player and the target sphere are a actors which are constantly moving and changing their transforms so this BP should take that into consideration. If it helps, I’m trying to mimic a kick of a football and the impact on the ball surface should be determined by means described above.

I did manage to get kicking straight ahead working (the one where yellow arrow is pointing directly at the crossing the two axis) but I’m stuck with the rotations. Also I’m open to other suggestions how to do this but I figured offsetting the start position before tracing would be the easiest way since I could get impact point and normal on the sphere straight from the trace result.

I have a feeling this might be a no brainer but I’ve been at it for 2 days and just can’t figure it out. :slight_smile:

Thanks in advance.

So I managed to get the rotation around red axis (look attachments of above post) to work. I attached section of the blueprint where I do the rotation for the red axis.

Now I’m trying to figure out how to do the green one but I’m not sure how to do this one so any help would be appreciated.

Thanks in advance.

Back ago, I didnt understand how the rotate vector works, so i made my own989724f45134e9ed326fe3e41dde19f2c56a25a3.png

Thank you. I did not even know there is Math Expression nodes so that’s new. :slight_smile:

I’ll definetly look into that. Couple questions for starters though. If I would like to rotate x and y by different amounts I just bring two angle values in plugging the X for the top one and Y for the bottom one right? Do you have example where you use this in a blueprint as I’d like to see how you calculate the incoming Vectors?