Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 17,758 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
rotate player the shortest way #258617
03/31/09 22:01
03/31/09 22:01
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Hi..
I created this Script:
Code:

function rotate(h_direction)
{
	while(sign(ang(h_direction - player.pan)) != 0)
	{
		h_directionset = sign(ang(h_direction - player.pan));

		player.pan += (h_directionset*20)*time_step;
		if(fraction(player.pan) >= 0.5)
		{
			player.pan = integer(player.pan)+1;
		}else
		{
			player.pan = integer(player.pan);
		}
		wait(1);
	}

}


This rotates the player to an angle i choose. In my RPG, they are 0 / 360, 90, 180, 270.


The Problem:
Wehn the FPS are low, the player looks like he is shaking...


Do you know a better way???


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: rotate player the shortest way [Re: Espér] #258619
03/31/09 22:21
03/31/09 22:21
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
while(sign(ang(h_direction - player.pan)) != 0)

make that a range instead of one value. The player angle will never precisely end at 0. Then, when you quit the while loop, correct the tiny deviation in the angle to the exact rotation it should be facing.


Click and join the 3dgs irc community!
Room: #3dgs
Re: rotate player the shortest way [Re: Joozey] #258620
03/31/09 22:23
03/31/09 22:23
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
ok.. how to create a range????


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: rotate player the shortest way [Re: Espér] #258625
03/31/09 23:10
03/31/09 23:10
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
while angle is not between -5 and 5
Or whatever range you need for your computation.


Click and join the 3dgs irc community!
Room: #3dgs
Re: rotate player the shortest way [Re: Joozey] #258629
03/31/09 23:27
03/31/09 23:27
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
hmm..
tried this:
Code:
function rotate(h_direction)
{
	while(sign(ang(h_direction - player.pan)) >= -5 && sign(ang(h_direction - player.pan)) <= 5)
	{
		h_directionset = sign(ang(h_direction - player.pan));

		player.pan += (h_directionset*20)*time_step;
		if(fraction(player.pan) >= 0.5)
		{
			player.pan = integer(player.pan)+1;
		}else
		{
			player.pan = integer(player.pan);
		}
		wait(1);
	}

}


but same problem ( sometimes, it looks like 2 models are rotating against each other )..


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: rotate player the shortest way [Re: Espér] #258845
04/02/09 13:06
04/02/09 13:06
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: rotate player the shortest way [Re: VeT] #258852
04/02/09 13:45
04/02/09 13:45
Joined: Jan 2005
Posts: 605
Deutschland, NRW
G
garv3 Offline
User
garv3  Offline
User
G

Joined: Jan 2005
Posts: 605
Deutschland, NRW
Yeah! And a very young post...


GameStudio Version: A7 Pro v7.86
Re: rotate player the shortest way [Re: garv3] #259037
04/03/09 14:53
04/03/09 14:53
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
uhm.. plz don´t think i´m stupid.. but.. can someone comment out this code:
Code:
vec_set (temp_enemy_rotate.x, destination_node.x); 
vec_sub (temp_enemy_rotate.x, my.x);
vec_to_angle (temp_enemy_rotate_2.x, temp_enemy_rotate.x);
if(my.pan == temp_enemy_rotate_2.x)
{
my.pan=my.pan;
}
else
{
rotate_result = ang(temp_enemy_rotate_2.x - my.pan);
if (rotate_result > 0)my.pan += 20 * time_step;
if (rotate_result < 0)my.pan -= 20 * time_step; 
if ((ang(temp_enemy_rotate_2.x - my.pan) < 0) && (rotate_result > 0))	my.pan = temp_enemy_rotate_2.x; 
if ((ang(temp_enemy_rotate_2.x - my.pan) > 0) && (rotate_result < 0))	my.pan = temp_enemy_rotate_2.x;


because i think i´ve a blackout.. can´t say how this should working with a 90° by 90° rotation.. >.<


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: rotate player the shortest way [Re: Espér] #259048
04/03/09 16:10
04/03/09 16:10
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
looking like it isnt the best variant.. try this

Code:
void BotTurnTo(ENTITY* ent, VECTOR* targ_vec)
{
	var temp[3];
	
	vec_diff(temp,ent.x,targ_vec);
	vec_to_angle(targ_vec,temp);
	
	ent.pan -= sign(ang(180 + ent.pan - targ_vec.x)) * 5 * time_step;
}



1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: rotate player the shortest way [Re: VeT] #259071
04/03/09 17:48
04/03/09 17:48
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
hmm.. i think i do something wrong..
If the palyer shoudl rotate to 180, do i need to call it like that:

BotTurnTo(my, vector(180,0,0));

???


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1