Could somebody please tell me what I'm missing?
I have a scene where the camera is fixed in the sky looking down on a plane. On that plane is a 3D model. I want to move the 3D model in the direction of the mouse whenever the person clicks. I have accurately converted the mouse coordinates into 3D coordinates and then according to my understanding all I had to do was the following:
direction = new Vector3(mouseX - modelX, 0, mouseZ - modelZ);
direction = Vector3.Normalize(direction);
However this doesn't quite work. If I remove the normalize part and divide it by 100 it works as in it moves towards the mouse but the speed is constantly changing (as it should) since I'm just dividing by 100, so I sorta-kinda-know the rest is fine. But if I get rid of that and keep the normalize part the character goes crazy and moves towards the mouse but it moves very fast and is constantly flashing in different positions around the mouse. In 2D I had to use sin and cosine after subtracting the values from one another, is there something similar I have to do in 3D?
Thanks!
Edit - code for figuring out the mouse position:
nearsourceV = graphicsDevice.Viewport.Unproject(new Vector3(mouse.X, mouse.Y, 0f), camera.Projection, camera.View, camera.World);
farsourceV = graphicsDevice.Viewport.Unproject(new Vector3(mouse.X, mouse.Y, 1f), camera.Projection, camera.View, camera.World);
fullMouseCoord = Vector3.Normalize(farsourceV - nearsourceV);
mY = -fullMouseCoord.Y;
mY = zoomAmount / mY;
fullMouseCoord = fullMouseCoord * mY;
And then the code for updating the model position:
public void MoveVertices(float x2, float y2, float z2)
{
for (int i = 0; i < vertices.Length; i++)
{
vertices[i].Position.X += x2;
vertices[i].Position.Z += z2;
}
}