|
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
Senior Expert
|
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!
|
|
|
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
Serious User
|
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: jumpman]
#466345
06/10/17 09:26
06/10/17 09:26
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
Serious User
|
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
I just use the 'you' pointer that c_trace returns (if the trace hits something). 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)
|
|
|
|