• News

• Industries

• Learning & Support

• Community

• Marketplace

Rotating Vectors around a point

I have a cube with different coloured sides.
I have a line trace set up to determine if the cube is being looked at and to provide a hit location.
I need to work out from this which side is being looked at.

So far I have it working if the cube hasn’t rotated at all.
I get the actor location and minus the hit location which gives me a vector where one of the values will be 50 or -50 (The cube is 100 units square).
From this I can determine which of the six sides is active.

I’m not sure how to get this to work when rotated.

I thought that maybe I could somehow rotate the hit location around the cubes centre point by the same amount that the cube has rotated and calculate it from that new point?
Does that make any sense?
Is it possible at all?

Stupid question but is it important to rotate the whole actor?
Couldn’t you just rotate the mesh and maybe a socket or something and just leave the actor as it is? Like that the same detection function will always work and you can then just add new rotations to the current one from your mesh.

Just a random idea.

Besides that there is a “Rotate Vector Around Axis” (or very similar). That one takes two vectors as input and a float (for how many degree you want to rotate it). The first vector is your current vector, the second one is the vector it should rotate around. Maybe that already solves your issue

Cheers

EDIT: Alright. Perfect solution from mpie… You can never learn enough

If you inverse transform your hit location, you should receive your hit location in local space (not rotated and not scaled etc.)

Works a treat. Thanks for your help.
Been trying to work this out for a while now