first of all thanks for your reply GeniusPooh.I am sorry I didn't get all of it.I mean I am already unprojecting mouse positions at at both near and far plane in 3D world.what I want is to change the near point to player's position.I can't seem to get that working.As you can see I have tried to translate the near point to player's position and then calculated the direction of arrow from near near point to far point.But it still not working.Where am I wrong?
"slicer4ever" what you wrote worked but (even though the camera was behind the object) I had to explicitly add an offset value to the Y component of camera position to keep the camera up because it was at the same level as the object.I will really appreciate if you explain this "camera.position = object.position + object.forwardVector*(camera.offset.length/object.forwardVector.length)" to me.Thank you
I think I have made a mistake in describing my problem.Actually I am implementing a chase camera.I have two classes,the camera class and the object class(the 3D object the camera is chasing). Initially the camera is behind the object as some predefined offset.Now as I rotate the object its forward vector rotates along y-axis.In the camera class I have a camera position and a camera offset.The camera position is determined as "camera position=object position+camera offset".Now in order to keep the camera always behind the object I want to rotate the offset so that its parallel to object forward and then to get the new position of the camera I use the above equation(with the new transformed offset).What I need is a way or built in function that rotates the offset to object's forward every time I rotate my object.Thank you
My vector math has become a little rusty over the years of "no practice".So plz bear with me:).Thank You for your help