Skip to content

COP_update_object_local_template

Kamran Wali edited this page Dec 2, 2024 · 4 revisions

Inherits: Node

Node template script for creating new scripts containing all the local update object's methods and properties.

Description

COP_update_object_local_template is a Node template script. You can use this template script to create new scripts/objects that will act as a local update objects. You can also add these methods and properties to your script to make your script into an update object. It is the methods and properties that makes a script to an update object. Local update object means that the update manager property is referenced by dragging and dropping a node object that contains the base_update_manager script.

Tutorial

Properties

Type Name Default Value
COP_UpdateManager update_manager

Methods

Return Type Name
void update( float delta )
void set_active( bool is_enable )
bool is_active()
void on_enable()
void on_disable()
void _add_self_to_manager()
bool _is_update_object()

Property Descriptions

COP_UpdateManager update_manager

Resource reference to the update manager that will update this object per frame.


Method Descriptions

void update ( float delta )

This is the method that will be called per frame by the update manager which also depends on the update manager settings. This basically means that the logic you would usually put in _physics_process(delta) or _process(delta) must be put in here. The delta parameter provided here is the calculated delta from the update manager.


void set_active ( bool is_enable )

This method activates/deactivates this update object. Your logic for how the update object will be activated and deactivated MUST go here.

Note: Deactivating an update object will make the update manager NOT call the update object's update(delta). This will make the update manager skip the deactivated update object which in turn will save performance because the update object's logic will NOT be called. The update manager also uses the method is_active() to check if the update object is active or NOT.


bool is_active ()

This method is checked by the update manager to see if this update object is active or NOT. Give the logic here that will tell the update manager if the update object is active or NOT. True means active update object. False means deactive update object.

NOTE: A deactivated update object will be skipped by the update manager. This means that the update(delta) method for the update object will NOT be called and thus will save performance because the update object's logic will NOT be called. The method set_active() activates/deactivates the update object.


void on_enable ()

This method is called when the update manager is enabled through script. If you want to give any logic that will be called when the update manager is enabled then put those logic here.

Note: This method is optional and can be removed from your script if NOT needed. This method is ONLY called by the update manager and should NOT be called from other scripts.


void on_disable ()

This method is called when the update manager is disabled through script. If you want to give any logic that will be called when the update manager is disabled then put those logic here.

Note: This method is optional and can be removed from your script if NOT needed. This method is ONLY called by the update manager and should NOT be called from other scripts.


void _add_self_to_manager ()

This method adds this update object to the referenced update_manager by the Automation logic.

Note: This method should NOT be called or overridden because it is ONLY used by the Automation logic in the editor mode.


bool _is_update_object ()

This method checks if the object is an update object, which it is, and always returns true. This is needed by the Automation logic to use duck typing to check if the object is an update object.

Note: This method should NOT be overridden or changed because it used by the Automation logic to check if the object is an update object.


Clone this wiki locally