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
Smooth Turning models?
Topic Started: Dec 6 2012, 07:54 AM (227 Views)
tizorna
Newbie
[ * ]
well i was wondering is there a good method to preform this in games, See I'm working hard on this one game but I don't know how this could be accomplished with my game, I'll give some code from my current project to show what i have.

Is there a way i could change this code a little to get the smooth rotation?

its using a 3rd person camera using perspective set to 0

This in my step invent for the player
Code:
 

if(keyboard_check_direct(ord('S')))
{
Move(0,obj_camera.roty + 0, -speed2);
roty = obj_camera.roty + 0;
}
if(keyboard_check_direct(ord('A')))
{
Move(0,obj_camera.roty + 90, -speed2);
roty = obj_camera.roty + 90;
}
if(keyboard_check_direct(ord('D')))
{
Move(0,obj_camera.roty + 270, -speed2);
roty = obj_camera.roty + 270;
}
if(keyboard_check_direct(ord('W')))
{
Move(0,obj_camera.roty + 180, -speed2);
roty = obj_camera.roty + 180;
}
if keyboard_check_direct(ord('W')) && keyboard_check_direct(ord('A'))
{
roty = obj_camera.roty + 135;
}
if keyboard_check_direct(ord('W')) && keyboard_check_direct(ord('D'))
{
roty = obj_camera.roty + 225;
}
if keyboard_check_direct(ord('S')) && keyboard_check_direct(ord('A'))
{
roty = obj_camera.roty + 45;
}
if keyboard_check_direct(ord('S')) && keyboard_check_direct(ord('D'))
{
roty = obj_camera.roty + 315;
}
moving_direction=point_direction(xprevious2,yprevious2,x,y)+270;


i hope this code helps
Edited by tizorna, Dec 6 2012, 08:17 AM.
Offline Profile Quote Post Goto Top
 
RonBurgundy
Member Avatar
Forum Borat
[ *  *  *  *  *  * ]
Refer to this topic(lol refer).

http://s9.zetaboards.com/Ultimate3D_community/topic/7326278/1/#new

Or quite simply use angle differnce, compare if the angle difference is positive or negative, then set roty +=1 or -=1. Google angle_difference game maker you'll find the script.
!!! DEFEND POP PUNK !!!
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
Doesn't GameMaker have some sort of a lerp function?
Offline Profile Quote Post Goto Top
 
Reikyrr
Forum God
[ *  *  *  *  *  * ]
EDIT* In the snippet, replace distance with direction
I made an example in PHP to get the distance in degrees.
http://reikyrr.nl/snippets/distance.txt
PHP should not be to hard to translate to GML.

variables are seen by the $ mark.

You should put this into a function.

$distance is the direction your model is in.
$point_distance is the direction you want it pointed in.

you get negative numbers for turning left.
positive numbers for turning right.
(You can then calculate the step size by deviding or something)
Edited by Reikyrr, Dec 12 2012, 01:35 AM.
~Inspirational quote~
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply