[No] Actor scripts stops ticking, based on players radius

Moderator: GZDoom Developers

Actor scripts stops ticking, based on players radius

Postby Steve5563 » Thu Sep 24, 2020 12:45 am

asking if it's possible to add a flag that will make an actors script go into a "stop ticking" state based on a player being outside of a radius distance value that you can set.
for example lets call this flag a "script active radius" for now.
this is mainly for cpu optimization for maps that have a lot of actors with scripts.
if used correctly by the map designer only the objects that the player is near should be active, kinda similar to what draw distance does.

also would it be possible to add another flag to the same actor to tell the engine if it needs to render this actor based on a radius value you can set. for example lets call this flag "actor render" for now.
if this flag has been added to the actor, the engine excludes this from rendering the actor until the player is inside the radius
could there also be a way to interpolate the actors alpha value over time,
eg.(35 tics) so the sprite texture doesn't suddenly appear and disappear in the level?

if the radius values are correctly set by the level designer,
with the "actor render" radius being a larger value then the "script active" radius value

you should be able to walk up to an actor which is currently being excluded by the engine for gpu rendering and the script ticking is stopped,
the alpha value of the actor is forced 0% in this state.
and as you get inside the gpu render radius the gengine now includes this object to be rendered you should also see the actors sprite/texture fade in from 0% alpha to the actors set alpha value.
which can have a fade to alpha value transition time of (35 tics)
now because the player is still not within the "script active" set valued radius. the actors script is not ticking yet (still saving cpu performance)
when the player gets inside the "script active" radius value the actor will start ticking away and run its scripting like normal.
when the payer walks out of the "script active" radius value the script stops ticking.
when the player gets back inside the "script active" radius value the actor will continue ticking away from where it last stopped.
and if the player goes outside of both of the "script active" and "actor render" radius, then the engine basically ignores them until you re enter those set value radius.

this would be useful for applying to actors that have scripts to help optimize the cpu performance when a large map has hundreds or over thousand actors to be used in a level ( map decoration )
the reason i have asked for this "script to stop ticking" feature is because i have noticed a performance issue with lots of actors that have scripts running compared to lots of actors that don't have any scripts.
i hope this makes some sort of sense. cheers
User avatar
Steve5563
 
Joined: 28 Jan 2019
Location: Australia

Re: Actor scripts stops ticking, based on players radius

Postby Graf Zahl » Thu Sep 24, 2020 12:48 am

You'll have to do this yourself in your script. As a generic option it adds more overhead than it saves because it's also run for the majority of actors not using it and adding new properties to the actor that add memory overhead as well. So the net effect would be negative.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 2 guests