3rd Person Camera |
![]() ![]() |
3rd Person Camera |
Nov 7 2009, 07:48 PM
Post
#1
|
|
|
Master of Shadows Group: GMC Member Posts: 152 Joined: 16-February 09 Member No.: 128562 |
How do i add a third person camera that you can:
Thanks. PS: If anybody would like to work on a 3D MMORPG PM me. PSS: Point me out to a good 3D movement system. |
|
|
|
Nov 7 2009, 08:27 PM
Post
#2
|
|
|
Whipslash Group: GMC Member Posts: 1439 Joined: 17-December 05 From: Finland Member No.: 41012 |
Tutorials. Check them out.
This post has been edited by -Oakleaf-: Nov 7 2009, 08:27 PM |
|
|
|
Nov 7 2009, 09:23 PM
Post
#3
|
|
|
^destroyed evil chicken^ Group: GMC Member Posts: 393 Joined: 18-January 07 From: The land of AUS Member No.: 68535 |
this is how I do it. (It has a slight problem when going above 45 degrees z, dont know why. If anyone can help, tell me)
CODE if mouse_check_button(mb_right) { cam_yr+=(mouse_y-mouse_yprevious)/5 cam_zr+=(mouse_x-mouse_xprevious)/5 } cam_xf=cam_xt-lengthdir_x(1,cam_zr)*mouse_wheel_p cam_yf=cam_yt-lengthdir_y(1,cam_zr)*mouse_wheel_p cam_zf=cam_zt-lengthdir_y(1,cam_yr)*mouse_wheel_p mouse_wheel_p is zoom ...t is to ...f is from ...r is rotation mouse...previous is used in my code because I hate the mouse being in the centre of the screen. you will need to reset it every end step to the current mouse x and y the /5 can be changed if it goes too fast As for rotating the camera, try this(in conjunction with my other system) CODE direction=point_direction(xf,yf,xt,yt) I have typed it up so it hopefully faces away from the camera. If it doesnt, swap the f's for the t's |
|
|
|
Nov 7 2009, 10:13 PM
Post
#4
|
|
|
Master of Shadows Group: GMC Member Posts: 152 Joined: 16-February 09 Member No.: 128562 |
if doesnt seem to work. could you post me an example please
|
|
|
|
Nov 7 2009, 11:26 PM
Post
#5
|
|
|
^destroyed evil chicken^ Group: GMC Member Posts: 393 Joined: 18-January 07 From: The land of AUS Member No.: 68535 |
Can you show us what you have done? It will get the job done a lot faster
|
|
|
|
Nov 8 2009, 03:30 AM
Post
#6
|
|
|
GMC Member Group: GMC Member Posts: 1357 Joined: 9-October 07 Member No.: 90249 |
here is some 3rd person camera code. zang is the left and right angle. yang is the up and down angle. you'll need to initialize them to 0.
CODE var xf,yf,zf,m;
if mouse_check_button_pressed(mb_right) { mousex=mouse_x; mousey=mouse_y; window_mouse_set(mousex,mousey); } if mouse_check_button(mb_right) { zang+=(mousex-window_mouse_get_x())/8; yang+=(mousey-window_mouse_get_y())/8; yang=min(89,max(-89,yang)); window_mouse_set(mousex,mousey); } xf=lengthdir_x(1,zang); yf=lengthdir_y(1,zang); zf=tan(degtorad(yang)); m=sqrt(sqr(dx)+sqr(dy)+sqr(dz))/-200; dx/=m; dy/=m; dz/=m; d3d_set_projection(xf,yf,zf,x,y,z,0,0,1); |
|
|
|
Nov 8 2009, 10:47 AM
Post
#7
|
|
|
Master of Shadows Group: GMC Member Posts: 152 Joined: 16-February 09 Member No.: 128562 |
________________________________________
ERROR in action number 2 of Step Event for object obj_pCam: In script scr_cammove: Error in code at line 21: m=sqrt(sqr(dx)+sqr(dy)+sqr(dz))/-200; at position 13: Unknown variable dx i placed the yang=0 and zang=0 in the create event of the obj_pCam = that is the object the camera rotates around. not the players direction. That way you can rotate the camera and player independently. i uploaded the file so if you could edit it and and upload it back here is it This post has been edited by Shadowrend: Nov 8 2009, 10:55 AM |
|
|
|
Nov 8 2009, 04:34 PM
Post
#8
|
|
|
GMC Member Group: GMC Member Posts: 1357 Joined: 9-October 07 Member No.: 90249 |
woops, part of the code should be fixed to this.
CODE m=sqrt(sqr(xf)+sqr(yf)+sqr(zf))/-200;
xf/=m; yf/=m; zf/=m; d3d_set_projection(x+xf,y+yf,z+zf,x,y,z,0,0,1); This post has been edited by slayer 64: Nov 8 2009, 04:35 PM |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 22nd November 2009 - 01:04 PM |