Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Imhotep, opm), 785 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
enemy following a path #225599
09/05/08 09:17
09/05/08 09:17
Joined: Aug 2008
Posts: 49
V
Vyse220 Offline OP
Newbie
Vyse220  Offline OP
Newbie
V

Joined: Aug 2008
Posts: 49
I've read in the manual about the path, i've created a simple path in WED, now I really don't understand how the code work, if i want that the enemy move along the path that I have created (and assigned) how must i do the code?
Someone can please make an example?
thx

Re: enemy following a path [Re: Vyse220] #225606
09/05/08 09:33
09/05/08 09:33
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
I could give you a simple code smile

You create a path in WED name it for example: way1 and add this action to your enemy smile

Code:
define MOVEMENT_SPEED, skill1;

action enemy_follow_path
{
	var dist = 0; // entity walk speed
	var LastPos[3];
	var Dir[3];
	
	path_set(my, "way1"); // Change way1 to the name of your path set in WED
	
	while(1)
	{
		path_spline(me,my.x,dist); // spline curve for smooth walking
		dist += 12*time_step; // change this to change the walk speed
		c_move(me,vector(1*time_step,0,0),nullvector,IGNORE_YOU); // this is for collision but you don´t need
		vec_diff(Dir,my.x,LastPos);
		vec_to_angle(my.pan,Dir);
		vec_set(LastPos,my.x);*/
		ent_animate(my, "run", my.MOVEMENT_SPEED, ANM_CYCLE);
		my.MOVEMENT_SPEED += 10 * time_step;
		
		wait(1);
	}
}


Re: enemy following a path [Re: Rasch] #225655
09/05/08 15:40
09/05/08 15:40
Joined: Aug 2008
Posts: 55
A
asd Offline
Junior Member
asd  Offline
Junior Member
A

Joined: Aug 2008
Posts: 55
könntest du das für mich nochmal erklären?

Re: enemy following a path [Re: asd] #225658
09/05/08 16:05
09/05/08 16:05
Joined: Sep 2005
Posts: 392
Y
yertari Offline
Senior Member
yertari  Offline
Senior Member
Y

Joined: Sep 2005
Posts: 392
In the above example, am i right in saying 'my' is the name you have used in your code to indicate the character following the waypoint? So if the character was a wizard, i would change my with wizard?

What about the 'me' variable.

Also if the character was near the player, what kind of code would then the character to stop foillowing the path and attack

Thanks

Steve


Arteria3d - Providers of quality 3d assets and game audio
Re: enemy following a path [Re: asd] #225663
09/05/08 16:21
09/05/08 16:21
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
@yertari

no! my is the entity who was given the action enemy_follow_path.

me and my is the same. you could replace it with my.

Vyse asked for a path code. Thats somehting else. But for example you could do a c_scan or c_trace. As long as the scan don´t hit a entity it follows the path else it is attacking

Code:
define MOVEMENT_SPEED, skill1;

action enemy_follow_path
{
	var dist = 0; // entity walk speed
	var LastPos[3];
	var Dir[3];
	
	var look_around;
	
	path_set(my, "way1"); // Change way1 to the name of your path set in WED
	
	while(1)
	{
		vec_set(look_around.x, vector(10000, 0, 0));

		vec_rotate(look_around.x, camera.pan);

		vec_add(look_around.x, camera.x);
		
		c_trace(my.x, look_around.x, IGNORE_ME | IGNORE_PASSABLE | USE_POLYGON);

		if(you == 1)
		{
			// attack code
		}
		else
		{
			path_spline(me,my.x,dist); // spline curve for smooth walking
			dist += 12*time_step; // change this to change the walk speed
			c_move(me,vector(1*time_step,0,0),nullvector,IGNORE_YOU); // this is for collision but you don´t need
			vec_diff(Dir,my.x,LastPos);
			vec_to_angle(my.pan,Dir);
			vec_set(LastPos,my.x);*/
			ent_animate(my, "run", my.MOVEMENT_SPEED, ANM_CYCLE);
			my.MOVEMENT_SPEED += 10 * time_step;
		}
		
		wait(1);
	}
}



@asd

Also zuerst lege ich soetwas wie eine Variable an. Eine Definition. Diese verweise ich auf Skill1. Theoretisch kannst du das ganze auch so sehen bzw. machen:

Code:
var MOVEMENT_SPEED;


Dannach schreibe ich die Action für die Entity welche ich dann auch dem Model in WED zuweise bzw per ent_create.

Nun werden INTERNE Variablen für die Action angelegt.

DAs wären:

Code:
var dist = 0;
var LastPos[3];
var Dir[3];


Selbstverständlich kannst du sie benennen wie du möchtest.

Dann kommt die Anweisung:

Code:
path_set(my, "way1");


was soviel heist wie lege für mich die Route/Weg mit dem Namen "way1" fest. Hast du also im WED einen Pfad kreiert und ihn way1 genannt wird die Entity sich sozusagen auf diesem Pfad nun entlang bewegen.

Nun kommt ein Befehlt den ich auch heute selber noch nicht ganz verstehe.

Code:
path_spline
soll laut Handbuch eine weiche Kurve an den jeweiligen Punnkten berechnen sodass die Bewegung gesmooth und nicht abgehackt wirkt. Allerdings bewegt dieser Befehl die Entity auch entlang des Splines. Und das ist es was ich nicht verstehe.

Jedenfalls erhöht sich mit dem Befehl

Code:
dist += 12*time_step;


die dist Variable die ja auch im path_spline drin steht, ergo bewegt sich die Figur.

Da ich gerade an einem Capture the Flag Spiel arbeite und testweise meine Figuren durch die Flagge laufen lasse, sodass sie diese aufnehmen musste ich feststellen das durch das alleinige bewegen durch path_spline keine Kollision zustande kam. also habe ich den Befehl:

Code:
c_move(me,vector(1*time_step,0,0),nullvector,IGNORE_YOU);


eingefügt wodurch dann eine Kollision zustande kam da c_move ja eine Kollisionsabfrage macht.

Code:
vec_diff


gibt die Differenz aus der Position der Entity und der Variable LastPos und speichert das in Variable Dir.

mit
Code:
vec_to_angle
dreht sich die Entity zur Position der Variable Dir.

Code:
vec_set
speichert die gegenwärtige Position der Entity in die Variable LastPos

Code:
ent_animate
ist dazu da um die Rennen Animation der Entity abzuspielen.

und
Code:
MOVEMENT_SPEED
letzendlich ist dazu da um die Animation auch voranzutreiben.

Ich verstehe den Code größtenteils. Allerdings bin ich mir bei ein paar Sachen noch unklar!

Re: enemy following a path [Re: Rasch] #225665
09/05/08 16:30
09/05/08 16:30
Joined: Aug 2008
Posts: 55
A
asd Offline
Junior Member
asd  Offline
Junior Member
A

Joined: Aug 2008
Posts: 55
also, ich habs soweit kapiert:)
könnte ich also den gegner auf den player ausrichten lassen, und schießen?
Code:
vec_to_angle(my.pan,playervector);

und das schiessen dann über
Code:
if (c_trace(my.x,playervector, IGNORE_PASSABLE | USE_POLYGON| SCAN_TEXTURE) >= 0)
{
Schuss();
}

machen???

also als grobes beispiel

Last edited by asd; 09/05/08 16:30.
Re: enemy following a path [Re: asd] #225710
09/05/08 20:21
09/05/08 20:21
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
Du hast es erfasst smile

Re: enemy following a path [Re: asd] #225720
09/05/08 20:41
09/05/08 20:41
Joined: Aug 2008
Posts: 49
V
Vyse220 Offline OP
Newbie
Vyse220  Offline OP
Newbie
V

Joined: Aug 2008
Posts: 49
Thx all for the help, the code work, but I still have some problem
Quote:
action enemy_follow_path
{
var dist = 0; // entity walk speed
var LastPos[3];
var Dir[3];
while (player == null) {wait (1);}
my.z = player.z;
my.event = destroy_them;
my.passable = off;
my.skill40 = 1;
my.skill10 = 1;
path_set(my, "path_002"); //he name of your path set in WED

while(my.skill10 == 1)
{
path_spline(me,my.x,dist); // spline curve for smooth walking
dist += 12*time_step; // change this to change the walk speed
c_move(me,vector(1*time_step,0,0),nullvector,IGNORE_YOU); // this is for collision but you don´t need
vec_diff(Dir,my.x,LastPos);
vec_to_angle(my.pan,Dir);
vec_set(LastPos,my.x);
my.MOVEMENT_SPEED += 10 * time_step;

wait(1);
}
ent_remove(me);
}

Quote:

//part of the destroy_them function
if (my.skill40 == 1) // a ship was hit?
{
my.skill10 = 0;
if (you.skill40 == 99) // if it was player's bullet
{
score_value += 100; // get 100 points for a ship
}
effect(particles_explo2, 30, my.x, nullvector);
}

I've modified the code for make it be destroyed by the bullets of the player, but the enemy simple doesn't get demage, skill10 still remain 1 cause it continue to move

Re: enemy following a path [Re: Vyse220] #225723
09/05/08 20:54
09/05/08 20:54
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
you have a enemy ship that follows a path and when it hits the player ship it get destroyed? The player also can shoot at it and destroy it?

Re: enemy following a path [Re: Rasch] #225732
09/05/08 21:19
09/05/08 21:19
Joined: Aug 2008
Posts: 49
V
Vyse220 Offline OP
Newbie
Vyse220  Offline OP
Newbie
V

Joined: Aug 2008
Posts: 49
the ship can only be destroyed by the ship bullet(skill40=99), i've used that code, but it doesn't work

Page 1 of 2 1 2

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