Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
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,459 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
The blind enemies #157616
09/28/07 20:22
09/28/07 20:22
Joined: Jan 2007
Posts: 110
USA East Coast
K
KojaK Offline OP
Member
KojaK  Offline OP
Member
K

Joined: Jan 2007
Posts: 110
USA East Coast
In my game, my eneimes are following curved paths. They get the angle by

Code:

vec_set(temp,you.x);
vec_sub(temp,my.x);
vec_to_angle(zombang,temp);



then they get the angle behind them:

Code:

my.tilt = 0;
panopposite = ang(my.pan + 180);



now they compare the angle of the target(either the player if a trace is 0, or their next node(parenthandle) if the trace is >0) against the angle behind them and thier pan. If it is between their pan and thier pan + 180, add 4.5 to their pan. if not, it must be on the right, so subract 4.5.

Code:

if((panopposite >= zombang) && (my.pan <= zombang)){
turnspeed = 4.5 * time_step;
}
else{
turnspeed = -4.5 * time_step;
}
if(my.pan < ang(temp.z - 6) || my.pan > ang(temp.z + 6)){
ang_add(my.pan, vector(turnspeed, 0, 0));
}



however, this does not work. If they can see you, they work, turning left and right. But if you are past the pan + 180 range, but behind a certain angle, they ignore you, turn tward the 0 angle direction, and proceed to walk along it.

This applies not only to the player, but any target they are told to walk to. If the next node is on their left, they ignore it, and just walk forward. If I invert the greater than and less than, and reverse the positive 4.5 and negative 4.5, so that it reads:
Code:

if((panopposite <= zombang) || (my.pan >= zombang)){
turnspeed = -4.5 * time_step;
}
else{
turnspeed = 4.5 * time_step;
}


It will invert the blind side. I don't know what side the code I have posted makes blind, but I do know that it isn't the whole side. A couple of degrees off is where it starts, because the zombies do follow you, until you get far enough to one side. All i want this code to do is find the quickest way to turn to get to the target, while still keeping a curved path.

If anyone can tell me what is wrong with this code, please do so. Or, if anyone has a fix, or a work-around, just let me know.


Lead programmer for Two Screws Loose Click here for our forums, and downloads for our games
Re: The blind enemies [Re: KojaK] #157617
10/01/07 20:05
10/01/07 20:05
Joined: Jan 2007
Posts: 110
USA East Coast
K
KojaK Offline OP
Member
KojaK  Offline OP
Member
K

Joined: Jan 2007
Posts: 110
USA East Coast
I've tried everything, from adding more if's, or messing with the sequence, but I can't find the problem!!

I have found out though, that if you simply switch the && to an ||, or vice versa, it switches the blind side. You don't have to switch the < or >.

Does anyone know of a way to tell if the enemy is on the left or right?


Lead programmer for Two Screws Loose Click here for our forums, and downloads for our games
Re: The blind enemies [Re: KojaK] #157618
10/02/07 19:42
10/02/07 19:42
Joined: Jan 2007
Posts: 110
USA East Coast
K
KojaK Offline OP
Member
KojaK  Offline OP
Member
K

Joined: Jan 2007
Posts: 110
USA East Coast
Okay, maybe you guys will help me now, I've located a problem.

If I place turnspeed = -4.5*time_step; before the if statement, and remove the else, it seems that they don't turn at all. They just keep walking forward. Does anyone know what would cause that to happen?


Lead programmer for Two Screws Loose Click here for our forums, and downloads for our games
Re: The blind enemies [Re: KojaK] #157619
10/02/07 19:45
10/02/07 19:45
Joined: Jan 2007
Posts: 221
F
Fenriswolf Offline
Member
Fenriswolf  Offline
Member
F

Joined: Jan 2007
Posts: 221
Hi,

I do not fully understand what you want to achieve, but "to tell if the enemy is on the left or right" you can do the following:
(I did not use the code-Tags here, as the code was strangely messed up)

vev_diff(temp,you.x, my.x);
vec_to_angle(zombang,temp);

var angleDifference[2];
angleDifference.pan = ang(zombang.pan - my.pan);

// this code is inelegent as it is just an example
if (angleDifference.pan > 0) { my.pan -= 4.5*time_step; }
if (angleDifference.pan < 0) { my.pan += 4.5*time_step; }

Re: The blind enemies [Re: Fenriswolf] #157620
10/02/07 19:54
10/02/07 19:54
Joined: Jan 2007
Posts: 110
USA East Coast
K
KojaK Offline OP
Member
KojaK  Offline OP
Member
K

Joined: Jan 2007
Posts: 110
USA East Coast
I will try that!

Thanks a bunch, I was trying everything from absolute values to while loops...

I will let you know how it works out.


Lead programmer for Two Screws Loose Click here for our forums, and downloads for our games
Re: The blind enemies [Re: KojaK] #157621
10/03/07 19:43
10/03/07 19:43
Joined: Jan 2007
Posts: 110
USA East Coast
K
KojaK Offline OP
Member
KojaK  Offline OP
Member
K

Joined: Jan 2007
Posts: 110
USA East Coast
IT WORKED!! I'M SO HAPPY!!


Lead programmer for Two Screws Loose Click here for our forums, and downloads for our games

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