Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Mouse-Camera Movement; yes well hmm...
Topic Started: Sep 15 2007, 02:24 PM (278 Views)
LaserLemon
Member Avatar
Sir
[ *  *  *  *  *  * ]
This one, I find slightly tricky, but I'll try to explain it as thoroughly as possible, okay.

The camera I'm using is in 3rd person and it follows my character, so far I've got this to run acceptably but it's not exactly working 100%, nevertheless, it follows my character but I want to make it possible to rotate the camera yourself by using the mouse. When you click and you keep pressing the button, moving the mouse rotates the camera, but how.

What code should I use in the mouse keep pressed event? :wacko:
Posted Image

Formerly known as FaTaL_N00B.
Offline Profile Quote Post Goto Top
 
Zip
Member Avatar
Forum Leader
[ *  *  *  *  * ]
This is simple:
the camera object have 2 variables: rotatex and rotatey. Those variable defines the orientation respect to the 'follow' object rotx and roty. Sou if you want to rotate the view around the player you need that code:
Code:
 

//player step event
//i assume that for rotating you have used GetMousePos() and SetMousePos(...)
//to retrieve the camera rotation general offsets, and saved those values to
//proper variables (eg. delta_x and delta_y)
if keyboard_check_direct(mb_right)
{
rotx_offset+=delta_x;
roty_offset+=delta_y;
}
else
{
//the previous camera/player turn code (i don't know how you have done it)
}

camera.rotatex=rotx_offset;
camera.rotatey=roty_offset;


You can improve that code so when the player moves the variables rotx_offset and roty_offset resets to 0.
Sorry if i've made some errors, I'm not english!
Offline Profile Quote Post Goto Top
 
LaserLemon
Member Avatar
Sir
[ *  *  *  *  *  * ]
Quote:
 
if keyboard_check_direct(mb_right)


:blink: Can this be right, I mean, it IS a mouse button and isn't part of the keyboard. Doesn't this make more sense?

Code:
 
if mouse_button_pressed(mb_right)
Posted Image

Formerly known as FaTaL_N00B.
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
The state of the mouse buttons can't be checked by the regular mouse functions of Game Maker when :U3D: is active, so keyboard_check_direct(...) has to be used. It may seem a bit strange, but it works ;).
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
Zip
Member Avatar
Forum Leader
[ *  *  *  *  * ]
Holy words ;)
Sorry if i've made some errors, I'm not english!
Offline Profile Quote Post Goto Top
 
LaserLemon
Member Avatar
Sir
[ *  *  *  *  *  * ]
Strange... I don't see any holes in them... :lol: LOL, Just Kidding.
Posted Image

Formerly known as FaTaL_N00B.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply