Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 7th_zorro), 935 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
c_scan and vec_to_angle #304745
01/10/10 16:47
01/10/10 16:47
Joined: Aug 2004
Posts: 87
IDontLikeSoccer Offline OP
Junior Member
IDontLikeSoccer  Offline 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 blush 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 Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
1:
Code:
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:
Code:
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: Rei_Ayanami] #304759
01/10/10 18:20
01/10/10 18:20
Joined: Aug 2004
Posts: 87
IDontLikeSoccer Offline OP
Junior Member
IDontLikeSoccer  Offline OP
Junior Member

Joined: Aug 2004
Posts: 87
Hey Rei thank you verry much, i will try this...

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 Offline
Newbie
DR_Black  Offline
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 :

Code:
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 Offline OP
Junior Member
IDontLikeSoccer  Offline 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 confused

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 Offline
Newbie
DR_Black  Offline
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)
Code:
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
Code:
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 Offline OP
Junior Member
IDontLikeSoccer  Offline OP
Junior Member

Joined: Aug 2004
Posts: 87
I still have problem with first question, i try all codes but wont work frown .
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:

Code:
E entity
< player walk left
> player walk right
        
          E
                  
  >              <
-------------------- // player_look_at_entity = 1;


          E

  <              >
-------------------- // player_look_at_entity = 0;





Thx

Re: c_scan and vec_to_angle [Re: IDontLikeSoccer] #305069
01/12/10 19:33
01/12/10 19:33
Joined: Aug 2004
Posts: 87
IDontLikeSoccer Offline OP
Junior Member
IDontLikeSoccer  Offline OP
Junior Member

Joined: Aug 2004
Posts: 87
Please someone. I really need it frown

Re: c_scan and vec_to_angle [Re: IDontLikeSoccer] #305095
01/12/10 21:33
01/12/10 21:33
Joined: Jul 2004
Posts: 785
Serbia
Iglarion Offline
User
Iglarion  Offline
User

Joined: Jul 2004
Posts: 785
Serbia
Manual is your friend grin Simply use c_scan. Enjoy!

Code:
function scan_your_entity(){
	c_scan(player.x, player.pan, vector(100, 600, 300), ignore_me);
}

on_ctrl = scan_your_entity;


function skener() 
{
  if (event_type == EVENT_SCAN) 
  {
    you_see_entity = 1;
  }
}

action your_entity{
	static_entity=me;
	my.ENABLE_SCAN = ON; 
	my.event = skener;
}



Re: c_scan and vec_to_angle [Re: Iglarion] #305205
01/13/10 15:23
01/13/10 15:23
Joined: Aug 2004
Posts: 87
IDontLikeSoccer Offline OP
Junior Member
IDontLikeSoccer  Offline OP
Junior Member

Joined: Aug 2004
Posts: 87
Wooooork!!!
Thank you iglarion.


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