Download

How do I perform relative vector subtraction?

Hi, this is probably a pretty simple maths question but I’m rubbish at maths so here goes…

How do I subtract from a world vector , relative to a specific component? I just need the value, I’m not actually moving anything in the process.
To be more specific, I’m trying to get a certain point in space 10 units below a scene component attached to my camera.

Obviously the camera rotates so I can’t just do; StartVector - FVector(0,0,-10) as that just drops it down in world space. I need to drop it down relative to the scene component I’m reading the initial location from.

I could quite simply put another scene component in there but I was just wondering if there was a way to do it mathematically instead of littering up my class with reference components.

Hope I’ve explained well enough.

Cheers

Actually for anyone who comes across this, I think I may have the answer. You just have to use the ‘UpVector’ to subtract with or any of the other two if you want to do the other direction (ForwardVector, Right Vector)
Not sure if this is the best way but it seems to work fine.

And UpVector is exactly what you’d expect, essentially using it is the same as what you already tried.

CORE_API const FVector FVector::UpVector(0.0f, 0.0f, 1.0f);

Yes thanks for reiterating that , it’s a pretty simple thing but I’m terrible at maths haha