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
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 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 2 of 2 1 2
Re: [DONE-SUB]point to target slowly [Re: MMike] #205651
05/07/08 19:25
05/07/08 19:25
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
see: ang function in manual?
see: quaternions contribution thread (Lite-C)?
 Code:
/************************************
vfPan2
	ex-dump
	_vSrc: src pos (my.x)
	_vDest: dest pos (your.x, player.x, etc.)
	_3Step: 
		[_iPAN] = entity pan
		[_iSTEP] = turn step (multiplied by time)
	_vTmp: a temp vector 

	use:
		my.pan += vfPan2(my.x, player.x, vector(my.pan, 3.15, 0), temp);
			or
		temp.pan = vfPan2(my.x, player.x, vector(my.pan, 3.15, 0), temp);
		temp.tilt = 0; temp.roll = 0;
		c_rotate(me,temp,ignore_passable + ignore_passents + ignore_me + glide);
*************************************/
function vfPan2(&_vSrc ,&_vDest, &_3Step, &_vTmp) {
	//vec_set(_vTmp, nullvector);
	vec_diff(_vTmp, _vDest, _vSrc);
	vec_to_angle(_vTmp, _vTmp);
	_vTmp[0] = ang(_vTmp[0] - _3Step[iPAN]);
	_vTmp[1] = abs(_vTmp[0]);
	//if (_vTmp[1] < 0.10) {
		//return(_vTmp[0]);
	//}
	_vTmp[2] = ang(min(_vTmp[1], time * _3Step[iSTEP]) * sign(_vTmp[0]));
	return(_vTmp[2]);
}


Re: [DONE-SUB]point to target slowly [Re: testDummy] #205653
05/07/08 19:38
05/07/08 19:38
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
i don't understand c-lite too much. :S just some command i recognize.. but what that command does?

Re: [DONE-SUB]point to target slowly [Re: MMike] #205678
05/07/08 22:08
05/07/08 22:08
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
clarification, or worse:
The posted code, which might not work at all, but did seem to for something, is not Lite-C. It is C-Script, for rotating an entity toward a point, gradually, with no overshoot, but only for pan, ...or maybe it's alphabet soup instead.
(Function vf (vector function) Pan2 (pan to) is supposed to be similar to the above function actor_turnto?)

quoting manual for function ang (should be a command for C-Script and Lite-C):
 Quote:

ang(x)
Shifts the angle x into the -180 .. +180 range by adding or subtracting a multiple of 360 degrees. Often useful for calculating angle differences.
Returns:
Same angle, shifted into the -180 .. +180 range.


A thread in category Lite-C contributions is referred to for Lite-C and quaternions.
Perhaps there was a misunderstanding here, and the information offered is irrelevant.
'My' knowledge on many topics is very limited.


Re: [DONE-SUB]point to target slowly [Re: testDummy] #205680
05/07/08 22:55
05/07/08 22:55
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
I apreciate your code help, now about the ang(x) im confused..

the ang(x) didn't worked for me, because when the angle is for example 351.. it will return -45 .. and i just want positive number so i have to do:
if(angle<0){angle+=360;}

i will check if your code works

Re: [DONE-SUB]point to target slowly [Re: MMike] #207997
05/23/08 23:11
05/23/08 23:11
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
i should have posted this before, but i suppose this can help you:
Code:
FUNCTION rotate_entity_(rotate_angle,rotate_speed)
{
	IF (my.pan == rotate_angle) { return; }
	result = ang(rotate_angle - my.pan);
	IF (result > 0) { my.pan += rotate_speed * time_step; }
	IF (result < 0) { my.pan -= rotate_speed * time_step; }
	IF (ang(rotate_angle - my.pan) < 0 && result > 0) { my.pan = rotate_angle; }
	IF (ang(rotate_angle - my.pan) > 0 && result < 0) { my.pan = rotate_angle; }
}

this is how you would use it:
Code:
vec_set (temp, you.x);
vec_sub (temp, my.x);
vec_to_angle (temp_pan, temp);
rotate_entity_(temp_pan,turn_speed_);
///if you want to keep tilt at 0, just add "my.tilt = 0;" right here


if you'd prefer to use c_rotate, then use this one:

Code:
FUNCTION rotate_entity_(rotate_angle,rotate_speed)
{
	var r;
	IF (my.pan == rotate_angle) { return; }
	r = ang(rotate_angle - my.pan);
	IF (r > 0) { c_rotate(me, vector(rotate_speed*time_step,0,0), ignore_passable); }
	IF (r < 0) { c_rotate(me, vector(-rotate_speed*time_step,0,0), ignore_passable); }
	IF (ang(rotate_angle - my.pan) < 0 && r > 0) { my.pan = rotate_angle; }
	IF (ang(rotate_angle - my.pan) > 0 && r < 0) { my.pan = rotate_angle; }
}



- aka Manslayer101
Page 2 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