I'm testing if a ray shooting from my mouse position, intersects with any of the transforms stored in a vector. But the problem is, if one of the transforms changes positions after it was stored in the vector, the positions in the vector remain the same:
1 2 3 4 5 6 7 8 9 10 11
Transform position_a;
Transform position_b;
std::vector<Transform> transforms;
transforms.push_back(position_a);
transforms.push_back(position_b);
position_b.GetPos()->x = 6.0f; // Change Position
ShootRay(); // for loop iterates through vector of transforms and test intersection
The ray thinks position_b is still in the same position when I call the ShootRay function.
Is there a way I can store items (in my case Transforms) in vectors by reference? That way I can change the position on the original variable and it will automatically change the referenced object in the vector?
Or do I have to to modify the item in the vector and just work with the object in the vector from there on? I'm a little confused. Thanks and hope I didn't make this confusing.