C
Clinton Wheeler
Guest
Hi All,
I am having an issue with the game I'm developing. I want the character to move towards the mouse pointer in 3D space, I am using the script I found on the GMC:
This works great, but only when my camera direction is at 90degrees. The game allows the user to rotate the camera direction with the middle mouse button and when I do this the character no longer moves towards the mouse (see preview below for example).
Screen capture GIF - Preview - Click here for example.
The camera direction is calculated like this:
And then the direction that the player object will face is done like this:
I have tried offsetting the point_direction with the actual camera direction but it doesn't seem to be always the same amount?
I am using GMS:2
If anyone can help I would greatly appreciate it
Regards,
GMWIZ
I am having an issue with the game I'm developing. I want the character to move towards the mouse pointer in 3D space, I am using the script I found on the GMC:
GML:
var _x = tde_aspect_ratio * dtan( tde_cam_fov /2 ) * (2 * window_mouse_get_x() / window_get_width() - 1);
var _y = dtan( tde_cam_fov /2 ) * (1 - 2 * window_mouse_get_y() / window_get_height());
tde_mouse_vec[0] = _x * tde_proj_mat[0] + (-_y) * tde_proj_mat[1] + tde_proj_mat[2]
tde_mouse_vec[1] = _x * tde_proj_mat[4] + (-_y) * tde_proj_mat[5] + tde_proj_mat[6]
tde_mouse_vec[2] = _x * tde_proj_mat[8] + (-_y) * tde_proj_mat[9] + tde_proj_mat[10]
Screen capture GIF - Preview - Click here for example.
The camera direction is calculated like this:
GML:
tde_cam_x = global.player_object.x - lengthdir_x( tde_cam_in, tde_cam_dir (CAM DIRECTION) );
tde_cam_y = global.player_object.y - lengthdir_y( tde_cam_in, tde_cam_dir (CAM DIRECTION) );
GML:
if not ( tde_view_dragging )
{
z_rot = -(point_direction(0, 0, tde_mouse_vec[0], tde_mouse_vec[1]));
}
I am using GMS:2
If anyone can help I would greatly appreciate it
Regards,
GMWIZ