3 registered members (Ayumi, Akow, AndrewAMD),
1,505
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
c_scan and vec_to_angle
#304745
01/10/10 16:47
01/10/10 16:47
|
Joined: Aug 2004
Posts: 87
IDontLikeSoccer
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2004
Posts: 87
|
I have two question: 1. Maybe my question is stupid for someone who used 3dgs about five years but how make something like this (i suppose with vec_to_angle): if (player.pan == my player look at entity){...}// i need check did player look on some entity 2. How write part of code for check did player have some airplane entity above his head. Example 200 quants up on z axis and 20 quants left or right on x axis? Tnx
|
|
|
Re: c_scan and vec_to_angle
[Re: IDontLikeSoccer]
#304756
01/10/10 17:59
01/10/10 17:59
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
Expert
|
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
1:
ANGLE temp_ang;
VECTOR temp_vec;
vec_set(temp_vec, entity_you_want_check.x);
vec_sub(temp_vec, player.x);
vec_to_angle(temp_ang, temp_vec);
if((player.pan > temp_ang.pan - 5)&&(player.pan < temp_ang.pan + 5)) //play with 5
{ //your code }
2:
VECTOR temp;
vec_set(temp, vector(player.x,player.y,player+200); //above the player's head
c_scan(temp, nullvector, vector(360,0,100), /*you have to look for the modes yourself*/);
if(you != NULL)
{
your code
}
|
|
|
Re: c_scan and vec_to_angle
[Re: IDontLikeSoccer]
#304769
01/10/10 19:29
01/10/10 19:29
|
Joined: Mar 2009
Posts: 40
DR_Black
Newbie
|
Newbie
Joined: Mar 2009
Posts: 40
|
Hi vec_to_angle is not a good way to achieve that(first question) because only pan is not matter, tilt must count too. I prefer using this :
if (NULL != vec_to_screen(entity_to_be_seen.x,camera)) // if the entity is inside the camera frustum
{
if(c_trace(player.x,entity_to_be_seen.x,IGNORE_ME) == 0) //and if there is no obstacle between player and entity
{
//do something();
}
}
every body got some dues in life to pay
|
|
|
Re: c_scan and vec_to_angle
[Re: DR_Black]
#304778
01/10/10 19:58
01/10/10 19:58
|
Joined: Aug 2004
Posts: 87
IDontLikeSoccer
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2004
Posts: 87
|
Not work, sorry guys but i forgot say i use c-script and i think ANGLE temp_ang; VECTOR temp_vec; VECTOR temp; ...is the Lite-C language For question 2 i now use vec_dist: if(vec_dist (player.x, my.x) < 200){......} This work good but i scan 200 quants up and around player. I need check only 200 quants above my player (z axis). Did vec_dist can this?
|
|
|
Re: c_scan and vec_to_angle
[Re: IDontLikeSoccer]
#304782
01/10/10 20:18
01/10/10 20:18
|
Joined: Mar 2009
Posts: 40
DR_Black
Newbie
|
Newbie
Joined: Mar 2009
Posts: 40
|
I forgot how to write C-Script, so it may have some errors. 1-check if the player looks at some entity (entity_to_be_seen)
if(vec_to_screen(entity_to_be_seen.x,camera)) // if the entity is inside the camera frustum
{
if(c_trace(player.x,entity_to_be_seen.x,IGNORE_ME) == 0) //and if there is no obstacle between player and entity
{
//do something();
}
}
2-To check whether my is above player
var temp2[3];
vec_set(temp,my.x);
vec_sub(temp, player.x);
vec_to_angle(temp2, temp);
if(vec_dist (player.x, my.x) < 200 && abs(temp2.y - 90) < 10 ) //play with 10
{
//my is above player in distance less than 200
}
every body got some dues in life to pay
|
|
|
Re: c_scan and vec_to_angle
[Re: DR_Black]
#304903
01/11/10 19:22
01/11/10 19:22
|
Joined: Aug 2004
Posts: 87
IDontLikeSoccer
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2004
Posts: 87
|
I still have problem with first question, i try all codes but wont work . I will try explain better what i need. I move my player only on x axis left and right, and z is my gravity (like in 2D games). I need when my player walk in some direction where is located some static entity (for this i use variable player_walk_direction) , how i can know did my moving direction looks at this static entity or player is turn back of this entity? Here example:
E entity
< player walk left
> player walk right
E
> <
-------------------- // player_look_at_entity = 1;
E
< >
-------------------- // player_look_at_entity = 0;
Thx
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|