Gamestudio Links
Zorro Links
Newest Posts
freewhyblogelsewhere
by 9489cpjf. 06/03/24 06:06
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,321 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19056 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: smooth rotate [Re: Loopix] #201882
04/11/08 20:38
04/11/08 20:38
Joined: Oct 2007
Posts: 116
S
sydan Offline
Member
sydan  Offline
Member
S

Joined: Oct 2007
Posts: 116
I don't have much time so this is quick, this is the code I use, it works but it will need adapting for your needs:

function fnct_avoid_ai()
{
while(me != null)
{
my.avoid_left = 0;
my.avoid_right = 0;
if (my.task != 3 && my.task != 4 && my.task != 5)
{
// do 'antenna' trace 1
vec_set(temp, vector (-400,0,0));
vec_rotate (temp,vector(my.pan+160,0,0));
vec_add(temp, my.x);
//ent_create(ball, temp, act_ball);
result = c_trace(my.x,temp,IGNORE_ME|IGNORE_PASSABLE|IGNORE_PUSH); // do a trace and make result = to the found value
if (result > 0)
{
//my.pan += 4;
my.avoid_right = 1;
}

// do 'antenna' trace 2
vec_set(temp, vector (-400,0,0));
vec_rotate (temp,vector(my.pan+200,0,0)); // gets a vector for the point shown by the angle so that the 'antenna' sticks out
vec_add(temp, my.x);
//ent_create(ball, temp, act_ball);
result = c_trace(my.x,temp,IGNORE_ME|IGNORE_PASSABLE|IGNORE_PUSH); // do a trace and make result = to the found value
if (result > 0)
{
my.avoid_left = 1;
//my.pan -= 3;
}
}

if(my.avoid_right == 1)
{
my.pan += 4;
}
if(my.avoid_left == 1)
{
my.pan -= 4;
}
if(my.avoid_right == 1 && my.avoid_left == 1)
{
my.pan += 4;
}
wait(1);
}
}


For some reason, my ambition always seems to beat my ability.
Re: smooth rotate [Re: sydan] #203194
04/20/08 10:20
04/20/08 10:20
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
HeelX, after having converted your code to c script, it turns out that was exactly what I need!
I had a function that was working, but it had the stupid alpha lock thing in it. not it's so much cooler :D... my rockets finally follow the player in a nice and smooth way \:\)


~"I never let school interfere with my education"~
-Mark Twain
Re: smooth rotate [Re: Germanunkol] #203195
04/20/08 10:31
04/20/08 10:31
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Cool ;\)

Re: smooth rotate [Re: HeelX] #205069
05/03/08 15:57
05/03/08 15:57
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
// thread (ir)relevant snippet dump
// op -> ignore
 Code:
var iPAN = 0;
var iSTEP = 1;

/************************************
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]);
}



Page 2 of 2 1 2

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

Gamestudio download | chip programmers | 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