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
5 registered members (AndrewAMD, monk12, TipmyPip, Quad, aliswee), 1,029 guests, and 6 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
C_trace or ent_next for entity Sight #466337
06/09/17 19:46
06/09/17 19:46
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Hi everyone

How do you handle entities seeing each other? Do you periodically c_scan, and then trace back in the entity event?

Or do you use Ent_next and go through every entity and trace to each one? (well each one that is eligible for being searched, like a my.searchable skill)

What are the advantages and disadvantages of each? Both need to iterate through the whole list somehow correct?

Scan's advantage is that you can specify the cone right?

Re: C_trace or ent_next for entity Sight [Re: jumpman] #466338
06/09/17 20:48
06/09/17 20:48
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
c_scan is probably using a balanced tree so I guess its a way faster (it isnt there for the lulz only)

Re: C_trace or ent_next for entity Sight [Re: Ch40zzC0d3r] #466339
06/09/17 21:45
06/09/17 21:45
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Well, maybe you could store those entities (you don't want to handle this for all entities on the level, right? not props etc, but probably only specific type of entities) in a list of entities, and cycle through it (I made this to handle all AI in one loop, but could be used for some other needs I guess)? Then you could make c_traces and other checks (if needed)? This is just an idea, and it might not be the best for your needs, cause I don't know what you want to archive (and I'm too noob anyway).

If we are talking about AI stuff, I usually use c_scan (f.e. when player shoots and walks, he makes c_scan check around in a circle, to attract enemies), that triggers AI and then I do c_trace (if needed). Aside from that, I use c_scan from AI itself, so it kinda looks around, and if player is within the scannig cone, then make a trace to make sure that we can see him (and he isn't behind the wall or something). Something like this, but I'm not sure about how fast is this going to be, probably depends on how many npcs are you going to have, plus maybe don't c_scan too offten, make somekind of counter or something.


Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: C_trace or ent_next for entity Sight [Re: 3run] #466341
06/09/17 22:15
06/09/17 22:15
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Don't use ent_next loop each frame, it is slow if you have lots of entities to cycle through. Easiest is to use c_scan for detection and than optionally trace to check if entity can really see other entity.
If you want to cycle through many / all objects, store those objects in a pointer array and loop through them in a for loop.
vec_dist can also be helpful and is fast.

Anyone actually know if it is faster to have separate whiles for entities or if you loop through them each frame in a for or while loop? I guess the latter right?

Last edited by Reconnoiter; 06/09/17 22:18.
Re: C_trace or ent_next for entity Sight [Re: Reconnoiter] #466343
06/10/17 02:27
06/10/17 02:27
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Whether I chose c_scan or ent_next, I was planning on letting entities take turns on who can use it. Since it's line of sight, there would need to be a c_trace as well. Do you all use a trace within the event_detect function, with a wait(1)?

If entities are taking turns scanning, why would a single while loop with all the scans be faster?

Re: C_trace or ent_next for entity Sight [Re: jumpman] #466345
06/10/17 09:26
06/10/17 09:26
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
I just use the 'you' pointer that c_trace returns (if the trace hits something).

Quote:
If entities are taking turns scanning, why would a single while loop with all the scans be faster?
, I mean have a single loop for all the entity actions (including your scan/trace code) which supposedly saves some fps but I don't really know how much. (I went slightly offtopic)

Re: C_trace or ent_next for entity Sight [Re: Reconnoiter] #466351
06/11/17 04:41
06/11/17 04:41
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Can I reliably and safely use a c_trace within an event_detect event with a wait(1)? (Ptr_for_handle as well to retrieve the entity if needed)


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