Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,089 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
<req> object avoidance #349119
12/04/10 06:29
12/04/10 06:29
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
does anyone have any object avoidance code? something simple is fine. the aum ones still use c contant. could make it myself but donwant to remake it if it was all ready done


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: <req> object avoidance [Re: PrenceOfDarkness] #349139
12/04/10 11:21
12/04/10 11:21
Joined: Aug 2009
Posts: 1,438
Spain
painkiller Offline
Serious User
painkiller  Offline
Serious User

Joined: Aug 2009
Posts: 1,438
Spain
Here it is, I adapted it some moths ago:

Code:
if(my.state==2) //chasing player
{
	if(c_trace(my.x, content_right, IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES)+c_trace(my.x, content_left, IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES)==0)
	{
		vec_set(temp_vec, player.x);  //turn smoothly to player
		vec_sub(temp_vec,my.x); 
		vec_to_angle(temp_angle, temp_vec);
		if(ang(temp_angle.pan - my.pan)<-2|ang(temp_angle.pan - my.pan)>2)	my.pan += sign(ang(temp_angle.pan - my.pan))*time_step*5;
	}
	vec_set(content_right, vector(50, -20, -15));
	vec_rotate(content_right, my.pan);
	vec_add(content_right, my.x);
	if(c_trace(my.x, content_right, IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES)!=0)
	{
		my.pan += 10 * time_step; // then rotate the enemy, allowing it to avoid the obstacle
	}
	vec_set(content_left, vector(50, 20, -15));
	vec_rotate(content_left, my.pan);
	vec_add(content_left, my.x);
	if(c_trace(my.x, content_left, IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES)!=0)
	{
		my.pan -= 10 * time_step; // then rotate the enemy, allowing it to avoid the obstacle
	}
	c_move (my, vector(10 * time_step, 0, 0), nullvector, GLIDE|IGNORE_PASSABLE);
	ent_animate(my, "run", my.animation_frame, ANM_CYCLE); // play the "run" animation
	my.animation_frame += 9 * time_step; // "9" controls the animation speed
	if(vec_dist(my.x, player.x)<500) //attack
	{
		my.state=3;
		my.animation_frame=0;
	}
	if(vec_dist(my.x, player.x)>2500) //stand
	{
		my.state=1;
		my.animation_frame=0;
	}
}




3D Gamestudio A8 Pro
AMD FX 8350 4.00 Ghz
16GB RAM
Gigabyte GeForce GTX 960 4GB
Re: <req> object avoidance [Re: painkiller] #349196
12/04/10 23:14
12/04/10 23:14
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
thanks painkiller your a time saver!

btw if you add an if state you can save the computer from runnning two slow traces. maybe at the second if as well.

Last edited by PrenceOfDarkness; 12/05/10 06:34.

"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: <req> object avoidance [Re: PrenceOfDarkness] #349267
12/05/10 15:55
12/05/10 15:55
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I'm having little problem with it, when I try to increase the turning speed, AI starts jerking.... How can I prevent that? laugh
I've tried to use 'ent_turnto' from A8's 'ent_move.c' library, but AI turns around its pan... May be that's because I try to use it with A7?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

Moderated by  adoado, checkbutton, mk_1, Perro 

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