I have attached a weapon to a FPS camera at position (10,-13,10).
Now I want to set the bullets's starting coordinates to the weapon
position. If I set the camera's position as starting point, the bullets
fly to their target as expected.
But If I add the vector of the weapon to start, the bullets fly to a fix
point which was not the point the camera aimed at.
If I add something like (0.1,0.1,0.1) to the camera pos, the result is still the same,
but not with higher values like (0.9,0.9,0.9).
I think I misunderstood something
Code: Select all
Bullet bullet;
// get line between camera1 and target
core::vector3df start = camera-> getPosition();
// X adjust starting position to match with attached weapon
// X start+=vector3df(10,-13,10);
std::cout << "start: "<<start.X <<" "<< start.Y <<" "<< start.Z <<std::endl;
core::vector3df end = (camera->getTarget() - start);
std::cout << "end1: "<<end.X <<" "<< end.Y <<" "<< end.Z <<std::endl;
end.normalize();
end = start + (end * (camera->getFarValue()));
std::cout << "end2: "<<end.X <<" "<< end.Y <<" "<< end.Z <<std::endl;
bullet.flight.setLine(start, end);
Code: Select all
start: 494.761 29.223 2179.93
end: -0.77536 0.0900536 0.625
end2: -1831.41 299.395 4055.01
Code: Select all
start: 480.78 16.2185 2180.85
end: -10.8089 13.0987 -9.42041
end2: -1188.94 2039.67 725.616