Polygon2d Animation

Godot Version

4.7

Question

Hello everyone.

Is this the right way to use a poligon2D in animation ?

For each bodyPart i have a polygon2D with vertices ( simillar to image Wrap in photoshop )

Each body part has 9 bones to move / deform the image.

All parts are inside a subViewport.

Does this make the polygon2D recreate all the vertices in every frame // physics delta time ?



Iam using this body type for all human enemies/entities,

with 10 enemies on screen it kinds of hangs to 10fps or 5fps for about 1 second when loading / running the game for the 1st time, but after that nothing special no cpu spikes or frame loss that i can see…

Not if you’re only using the skeleton to deform the polygon

It’s likely caused by shader compilation.

I dont think its shaders, it only happens with enemies on screen

its some kind of loading time…

Problem could be the enemie script is loading files in the ready function… same has the player…

this enemy component is being used on all enemies…

i dont know if he just reads the enemy component 1 time or 10 times for each enemie that gets spawn on the level ?

guard01 script

func _ready() -> void:
	
	colBox.shape = colBox.shape.duplicate();
	hurtShape.shape = hurtShape.shape.duplicate();
	ray_shape_2d.shape = ray_shape_2d.shape.duplicate();
	hole_shape_2d.shape = hole_shape_2d.shape.duplicate();
	wall_shape_2d.shape = wall_shape_2d.shape.duplicate();
	
	_setClothes();
	
	animIdle = _loadAnim("res://chars/enemy/anims/guard01idle.anim" );
	animWalk = _loadAnim("res://chars/enemy/anims/guard01walk.anim" );
	animReadyUP =  _loadAnim("res://chars/enemy/anims/guard01readyUP.anim" );
	animShootUP =  _loadAnim("res://chars/enemy/anims/guard01shootUP.anim" );
	animReadyDN =  _loadAnim("res://chars/enemy/anims/guard01readyDN.anim" );
	animShootDN =  _loadAnim("res://chars/enemy/anims/guard01shootDN.anim" );
	animCrouchOUT =  _loadAnim("res://chars/enemy/anims/guard01crouchOUT.anim" );
	animIdleShootUP =  _loadAnim("res://chars/enemy/anims/guard01idleShootUP.anim" );
	animIdleShootDN =  _loadAnim("res://chars/enemy/anims/guard01idleShootDN.anim" );
	animReadyENTER =  _loadAnim("res://chars/enemy/anims/guard01readyEnter.anim" );
	animPainUP =  _loadAnim("res://chars/enemy/anims/guard01PainUP.anim" );
	animPainDN =  _loadAnim("res://chars/enemy/anims/guard01PainDN.anim" );
	animFall =  _loadAnim("res://chars/enemy/anims/guard01Fall.anim" );
	animRise =  _loadAnim("res://chars/enemy/anims/guard01Rise.anim" );
	skel.root1 = animIdle;
	
	
	$direction/idleAlert.set_process_mode(Node.PROCESS_MODE_DISABLED);
	$direction/shoot.set_process_mode(Node.PROCESS_MODE_DISABLED);
	$direction/pain.set_process_mode(Node.PROCESS_MODE_DISABLED);
	$Timer.wait_time = patrolWaitSec;
	$Timer.start();
	font = FontFile.new();
	font.font_data = load('res://fonts/big_noodle_titling_0.ttf');
	
	
	_setEnemyWeapon();

every enemie human guy has the skelComponent, but the loads are in “guard01 script” He should just read the “skelComponent” one time ?

Are there any shaders on enemies?

Could also just be resource loading.

yes the component has a blur shader and an outline shader

but i think its resource loading, ive removed the 2 shaders and its the same

tried moving all the loading files to a global script but still the same,

The FPS only play normal with 1 enemie on screen with 10 enemies i think its loading 10 times. For about 1 second when the levels stars fps its at 5 or 10 fps then no problems normal fps… All the enemies are duplicate

i think i can only load this .anim files in the ready function…

heres the diference in loading sound files in a global preloaded script // and the anim files im loading

snd.gd

extends Node2D

const audioStr = preload("res://sounds/snd_effect.tscn");
const mgunFire_1 = preload('res://sounds/mgunFire_1.wav');
const pistolFire_1 = preload('res://sounds/pistolFire_1.wav');
const run_1 = preload('res://sounds/run_1.wav');
const run_2 = preload('res://sounds/run_2.wav');
const jumpLand = preload('res://sounds/land2.wav');
const jumpGo01 = preload('res://sounds/jumpGo01.wav');
const dodge01 = preload('res://sounds/dodge02.wav');
const elevDoorOpen01 = preload('res://sounds/elevDoorOpen01.wav');
const elevDoorClose01 = preload('res://sounds/elevDoorClose01.wav');
const elevLoop = preload('res://sounds/elevLoop.wav');
const elevLoop2 = preload('res://sounds/elevLoop2.wav');
const elevEnd = preload('res://sounds/elevEnd.wav');
const elevEnd2 = preload('res://sounds/elevEnd2.wav');

const fall = preload('res://sounds/fall.wav');
const die1 = preload('res://sounds/die1.wav');
const dieBlink1 = preload('res://sounds/dieBlink1.wav');

const menu_move1 = preload("res://sounds/menu_move1.wav");
const menu_move2 = preload("res://sounds/menu_move2.wav");
const menu_select1 = preload("res://sounds/menu_select1.wav");
const menu_select2 = preload("res://sounds/menu_select2.wav");
const menu_select3 = preload("res://sounds/menu_select3.wav");
const menu_slotHover1 = preload("res://sounds/menu_slotHover.wav");

const PickUP1 = preload("res://sounds/PickUp1.wav");



func playSnd( _sndEffect ):
	var _snd = audioStr.instantiate();
	add_child(_snd);
	_snd.stream = _sndEffect;
	_snd.play();

guard_01.gd


var animIdle;
var animWalk;
var animReadyUP;
var animShootUP;
var animReadyDN;
var animReadyENTER;
var animIdleShootUP;
var animIdleShootDN;
var animShootDN;
var animCrouchOUT;
var animPainUP;
var animPainDN;
var animFall;
var animRise;




func _ready() -> void:
	
	colBox.shape = colBox.shape.duplicate();
	hurtShape.shape = hurtShape.shape.duplicate();
	ray_shape_2d.shape = ray_shape_2d.shape.duplicate();
	hole_shape_2d.shape = hole_shape_2d.shape.duplicate();
	wall_shape_2d.shape = wall_shape_2d.shape.duplicate();
	
	_setClothes();
	
	
	animIdle = _loadAnim("res://chars/enemy/anims/guard01idle.anim" );
	animWalk = _loadAnim("res://chars/enemy/anims/guard01walk.anim" );
	animReadyUP =  _loadAnim("res://chars/enemy/anims/guard01readyUP.anim" );
	animShootUP =  _loadAnim("res://chars/enemy/anims/guard01shootUP.anim" );
	animReadyDN =  _loadAnim("res://chars/enemy/anims/guard01readyDN.anim" );
	animShootDN =  _loadAnim("res://chars/enemy/anims/guard01shootDN.anim" );
	animCrouchOUT =  _loadAnim("res://chars/enemy/anims/guard01crouchOUT.anim" );
	animIdleShootUP =  _loadAnim("res://chars/enemy/anims/guard01idleShootUP.anim" );
	animIdleShootDN =  _loadAnim("res://chars/enemy/anims/guard01idleShootDN.anim" );
	animReadyENTER =  _loadAnim("res://chars/enemy/anims/guard01readyEnter.anim" );
	animPainUP =  _loadAnim("res://chars/enemy/anims/guard01PainUP.anim" );
	animPainDN =  _loadAnim("res://chars/enemy/anims/guard01PainDN.anim" );
	animFall =  _loadAnim("res://chars/enemy/anims/guard01Fall.anim" );
	animRise =  _loadAnim("res://chars/enemy/anims/guard01Rise.anim" );
	skel.root1 = animIdle;
func _loadAnim( loadFileName ):
	var file = FileAccess.open(loadFileName, FileAccess.READ);
	var animFile  = file.get_var();
	file = null # File is closed.
	return( animFile );

You should cache loaded stuff, or better just use the built in resource loading mechanism instead of manually loading files and let the engine automatically cache them.

the problem is in skel component inside each character… its all coming from here. iam doing the rotations / transform, positions, etc.. in physics process even if its not at running every 60 fps it only updates when nextframe == true, with more than 30 enemies on screen the fps start to slow down…


#-------//----sets-parts-coord--//-------------------
func _ptSimplePath():
	#------------------//-----------------------//---------------------------------
	#-----------------//---UPPER-BODY-ROOT-1---//----------------------------------
	#----------------//-----------------------//-----------------------------------
	animFrame = clamp(animFrame, 0, root1.Fnum.size()-1 );
	
	if ( rootUpperBodySet == false ):
		#//-Left-Hand
		#pt1_spr.texture.set_current_frame( root1.Fnum[animFrame].pt1.fm );
		pt1_spr.texture = Lhand1[ root1.Fnum[animFrame].pt1.fm ];
		
		pt1_spr.position = root1.Fnum[animFrame].pt1.pos;
		bodyCollision.move_child ( pt1_spr, root1.Fnum[animFrame].pt1.pz );
		pt1_spr.rotation = root1.Fnum[animFrame].pt1.pa * (PI/180);
		pt1_up1.position = root1.Fnum[animFrame].pt1.up1;
		pt1_up2.position = root1.Fnum[animFrame].pt1.up2;
		pt1_up3.position = root1.Fnum[animFrame].pt1.up3;
		pt1_md1.position = root1.Fnum[animFrame].pt1.md1;
		pt1_md2.position = root1.Fnum[animFrame].pt1.md2;
		pt1_md3.position = root1.Fnum[animFrame].pt1.md3;
		pt1_dn1.position = root1.Fnum[animFrame].pt1.dn1;
		pt1_dn2.position = root1.Fnum[animFrame].pt1.dn2;
		pt1_dn3.position = root1.Fnum[animFrame].pt1.dn3;
		#//-Left-armDown
		#pt2_spr.texture.set_current_frame( root1.Fnum[animFrame].pt2.fm );
		pt2_spr.texture = LarmDn1[ root1.Fnum[animFrame].pt2.fm ];
		
		pt2_spr.position = root1.Fnum[animFrame].pt2.pos;
		bodyCollision.move_child ( pt2_spr, root1.Fnum[animFrame].pt2.pz );
		pt2_spr.rotation = root1.Fnum[animFrame].pt2.pa * (PI/180);
		pt2_up1.position = root1.Fnum[animFrame].pt2.up1;
		pt2_up2.position = root1.Fnum[animFrame].pt2.up2;
		pt2_up3.position = root1.Fnum[animFrame].pt2.up3;
		pt2_md1.position = root1.Fnum[animFrame].pt2.md1;
		pt2_md2.position = root1.Fnum[animFrame].pt2.md2;
		pt2_md3.position = root1.Fnum[animFrame].pt2.md3;
		pt2_dn1.position = root1.Fnum[animFrame].pt2.dn1;
		pt2_dn2.position = root1.Fnum[animFrame].pt2.dn2;
		pt2_dn3.position = root1.Fnum[animFrame].pt2.dn3;
		#//-Left-armUp
		#pt3_spr.texture.set_current_frame( root1.Fnum[animFrame].pt3.fm );
		pt3_spr.texture = LarmUp1[ root1.Fnum[animFrame].pt3.fm ];
		
		pt3_spr.position = root1.Fnum[animFrame].pt3.pos;
		bodyCollision.move_child ( pt3_spr, root1.Fnum[animFrame].pt3.pz );
		pt3_spr.rotation = root1.Fnum[animFrame].pt3.pa * (PI/180);
		pt3_up1.position = root1.Fnum[animFrame].pt3.up1;
		pt3_up2.position = root1.Fnum[animFrame].pt3.up2;
		pt3_up3.position = root1.Fnum[animFrame].pt3.up3;
		pt3_md1.position = root1.Fnum[animFrame].pt3.md1;
		pt3_md2.position = root1.Fnum[animFrame].pt3.md2;
		pt3_md3.position = root1.Fnum[animFrame].pt3.md3;
		pt3_dn1.position = root1.Fnum[animFrame].pt3.dn1;
		pt3_dn2.position = root1.Fnum[animFrame].pt3.dn2;
		pt3_dn3.position = root1.Fnum[animFrame].pt3.dn3;
		#//-torso
		
		#pt8_spr.texture.set_current_frame( root1.Fnum[animFrame].pt8.fm );
		pt8_spr.texture = Torso1[ root1.Fnum[animFrame].pt8.fm ];
		
		pt8_spr.position = root1.Fnum[animFrame].pt8.pos;
		bodyCollision.move_child ( pt8_spr, root1.Fnum[animFrame].pt8.pz );
		pt8_spr.rotation = root1.Fnum[animFrame].pt8.pa * (PI/180);
		pt8_up1.position = root1.Fnum[animFrame].pt8.up1;
		pt8_up2.position = root1.Fnum[animFrame].pt8.up2;
		pt8_up3.position = root1.Fnum[animFrame].pt8.up3;
		pt8_md1.position = root1.Fnum[animFrame].pt8.md1;
		pt8_md2.position = root1.Fnum[animFrame].pt8.md2;
		pt8_md3.position = root1.Fnum[animFrame].pt8.md3;
		pt8_dn1.position = root1.Fnum[animFrame].pt8.dn1;
		pt8_dn2.position = root1.Fnum[animFrame].pt8.dn2;
		pt8_dn3.position = root1.Fnum[animFrame].pt8.dn3;
		#//-head
		#pt9_spr.texture.set_current_frame( root1.Fnum[animFrame].pt9.fm );
		pt9_spr.texture = Head1[ root1.Fnum[animFrame].pt9.fm ];
		
		pt9_spr.position = root1.Fnum[animFrame].pt9.pos;
		bodyCollision.move_child ( pt9_spr, root1.Fnum[animFrame].pt9.pz );
		pt9_spr.rotation = root1.Fnum[animFrame].pt9.pa * (PI/180);
		pt9_up1.position = root1.Fnum[animFrame].pt9.up1;
		pt9_up2.position = root1.Fnum[animFrame].pt9.up2;
		pt9_up3.position = root1.Fnum[animFrame].pt9.up3;
		pt9_md1.position = root1.Fnum[animFrame].pt9.md1;
		pt9_md2.position = root1.Fnum[animFrame].pt9.md2;
		pt9_md3.position = root1.Fnum[animFrame].pt9.md3;
		pt9_dn1.position = root1.Fnum[animFrame].pt9.dn1;
		pt9_dn2.position = root1.Fnum[animFrame].pt9.dn2;
		pt9_dn3.position = root1.Fnum[animFrame].pt9.dn3;
		#//-Right-Hand
		#pt13_spr.texture.set_current_frame( root1.Fnum[animFrame].pt13.fm );
		pt13_spr.texture = Rhand1[ root1.Fnum[animFrame].pt13.fm ];
		
		pt13_spr.position = root1.Fnum[animFrame].pt13.pos;
		bodyCollision.move_child ( pt13_spr, root1.Fnum[animFrame].pt13.pz );
		pt13_spr.rotation = root1.Fnum[animFrame].pt13.pa * (PI/180);
		pt13_up1.position = root1.Fnum[animFrame].pt13.up1;
		pt13_up2.position = root1.Fnum[animFrame].pt13.up2;
		pt13_up3.position = root1.Fnum[animFrame].pt13.up3;
		pt13_md1.position = root1.Fnum[animFrame].pt13.md1;
		pt13_md2.position = root1.Fnum[animFrame].pt13.md2;
		pt13_md3.position = root1.Fnum[animFrame].pt13.md3;
		pt13_dn1.position = root1.Fnum[animFrame].pt13.dn1;
		pt13_dn2.position = root1.Fnum[animFrame].pt13.dn2;
		pt13_dn3.position = root1.Fnum[animFrame].pt13.dn3;
		#//-Right-armDown
		#pt14_spr.texture.set_current_frame( root1.Fnum[animFrame].pt14.fm );
		pt14_spr.texture = RarmDn1[ root1.Fnum[animFrame].pt14.fm ];
		
		pt14_spr.position = root1.Fnum[animFrame].pt14.pos;
		bodyCollision.move_child ( pt14_spr, root1.Fnum[animFrame].pt14.pz );
		pt14_spr.rotation =  root1.Fnum[animFrame].pt14.pa * (PI/180);
		pt14_up1.position = root1.Fnum[animFrame].pt14.up1;
		pt14_up2.position = root1.Fnum[animFrame].pt14.up2;
		pt14_up3.position = root1.Fnum[animFrame].pt14.up3;
		pt14_md1.position = root1.Fnum[animFrame].pt14.md1;
		pt14_md2.position = root1.Fnum[animFrame].pt14.md2;
		pt14_md3.position = root1.Fnum[animFrame].pt14.md3;
		pt14_dn1.position = root1.Fnum[animFrame].pt14.dn1;
		pt14_dn2.position = root1.Fnum[animFrame].pt14.dn2;
		pt14_dn3.position = root1.Fnum[animFrame].pt14.dn3;
		#//-Right-armUp
		#pt15_spr.texture.set_current_frame( root1.Fnum[animFrame].pt15.fm );
		pt15_spr.texture = RarmUp1[ root1.Fnum[animFrame].pt15.fm ];
		
		pt15_spr.position = root1.Fnum[animFrame].pt15.pos;
		bodyCollision.move_child ( pt15_spr, root1.Fnum[animFrame].pt15.pz );
		pt15_spr.rotation = root1.Fnum[animFrame].pt15.pa  * (PI/180);
		pt15_up1.position = root1.Fnum[animFrame].pt15.up1;
		pt15_up2.position = root1.Fnum[animFrame].pt15.up2;
		pt15_up3.position = root1.Fnum[animFrame].pt15.up3;
		pt15_md1.position = root1.Fnum[animFrame].pt15.md1;
		pt15_md2.position = root1.Fnum[animFrame].pt15.md2;
		pt15_md3.position = root1.Fnum[animFrame].pt15.md3;
		pt15_dn1.position = root1.Fnum[animFrame].pt15.dn1;
		pt15_dn2.position = root1.Fnum[animFrame].pt15.dn2;
		pt15_dn3.position = root1.Fnum[animFrame].pt15.dn3;
		#//-------head-MASK----------------
		hEx1_spr.texture = HeadExt1[ root1.Fnum[animFrame].hEx.fm ];
		
		hEx1_spr.position = root1.Fnum[animFrame].hEx.pos;
		bodyCollision.move_child ( hEx1_spr, root1.Fnum[animFrame].hEx.pz );
		hEx1_spr.rotation = root1.Fnum[animFrame].hEx.pa * (PI/180);
		hEx1_spr.scale = root1.Fnum[animFrame].hEx.scl;
		#//-------WEAPON----------------
		wp1_spr.position = weapFollow.position + ( root1.Fnum[animFrame].wp1.pos * bodyCollision.scale );
		wp1_spr.texture = wp1_spr.weapImg[ root1.Fnum[animFrame].wp1.fm ];
		
		move_child ( wp1_spr, viewCon.get_index() + root1.Fnum[animFrame].wp1.pz );
		wp1_spr.rotation = root1.Fnum[animFrame].wp1.pa * (PI/180);
		wp1_spr.scale = Vector2(1, 1) +  root1.Fnum[animFrame].wp1.scl;
	
	else:
		animFrame2 = clamp(animFrame2, 0, root2.Fnum.size()-1 );
		#------------------//-----------------------//---------------------------------
		#-----------------//---UPPER-BODY-ROOT-2---//----------------------------------
		#----------------//-----------------------//-----------------------------------
		#//-Left-Hand
		#pt1_spr.texture.set_current_frame( root2.Fnum[animFrame2].pt1.fm );
		pt1_spr.texture = Lhand1[ root1.Fnum[animFrame].pt1.fm ];
		
		pt1_spr.position = root2.Fnum[animFrame2].pt1.pos;
		bodyCollision.move_child ( pt1_spr, root2.Fnum[animFrame2].pt1.pz );
		pt1_spr.rotation = root2.Fnum[animFrame2].pt1.pa * (PI/180);
		pt1_up1.position = root2.Fnum[animFrame2].pt1.up1;
		pt1_up2.position = root2.Fnum[animFrame2].pt1.up2;
		pt1_up3.position = root2.Fnum[animFrame2].pt1.up3;
		pt1_md1.position = root2.Fnum[animFrame2].pt1.md1;
		pt1_md2.position = root2.Fnum[animFrame2].pt1.md2;
		pt1_md3.position = root2.Fnum[animFrame2].pt1.md3;
		pt1_dn1.position = root2.Fnum[animFrame2].pt1.dn1;
		pt1_dn2.position = root2.Fnum[animFrame2].pt1.dn2;
		pt1_dn3.position = root2.Fnum[animFrame2].pt1.dn3;
		#//-Left-armDown
		#pt2_spr.texture.set_current_frame( root2.Fnum[animFrame2].pt2.fm );
		pt2_spr.texture = LarmDn1[ root1.Fnum[animFrame].pt2.fm ];
		
		pt2_spr.position = root2.Fnum[animFrame2].pt2.pos;
		bodyCollision.move_child ( pt2_spr, root2.Fnum[animFrame2].pt2.pz );
		pt2_spr.rotation = root2.Fnum[animFrame2].pt2.pa * (PI/180);
		pt2_up1.position = root2.Fnum[animFrame2].pt2.up1;
		pt2_up2.position = root2.Fnum[animFrame2].pt2.up2;
		pt2_up3.position = root2.Fnum[animFrame2].pt2.up3;
		pt2_md1.position = root2.Fnum[animFrame2].pt2.md1;
		pt2_md2.position = root2.Fnum[animFrame2].pt2.md2;
		pt2_md3.position = root2.Fnum[animFrame2].pt2.md3;
		pt2_dn1.position = root2.Fnum[animFrame2].pt2.dn1;
		pt2_dn2.position = root2.Fnum[animFrame2].pt2.dn2;
		pt2_dn3.position = root2.Fnum[animFrame2].pt2.dn3;
		#//-Left-armUp
		#pt3_spr.texture.set_current_frame( root2.Fnum[animFrame2].pt3.fm );
		pt3_spr.texture = LarmUp1[ root1.Fnum[animFrame].pt3.fm ];
		
		pt3_spr.position = root2.Fnum[animFrame2].pt3.pos;
		bodyCollision.move_child ( pt3_spr, root2.Fnum[animFrame2].pt3.pz );
		pt3_spr.rotation = root2.Fnum[animFrame2].pt3.pa * (PI/180);
		pt3_up1.position = root2.Fnum[animFrame2].pt3.up1;
		pt3_up2.position = root2.Fnum[animFrame2].pt3.up2;
		pt3_up3.position = root2.Fnum[animFrame2].pt3.up3;
		pt3_md1.position = root2.Fnum[animFrame2].pt3.md1;
		pt3_md2.position = root2.Fnum[animFrame2].pt3.md2;
		pt3_md3.position = root2.Fnum[animFrame2].pt3.md3;
		pt3_dn1.position = root2.Fnum[animFrame2].pt3.dn1;
		pt3_dn2.position = root2.Fnum[animFrame2].pt3.dn2;
		pt3_dn3.position = root2.Fnum[animFrame2].pt3.dn3;
		#//-torso
		#pt8_spr.texture.set_current_frame( root2.Fnum[animFrame2].pt8.fm );
		pt8_spr.texture = Torso1[ root1.Fnum[animFrame].pt8.fm ];
		
		pt8_spr.position = root2.Fnum[animFrame2].pt8.pos;
		bodyCollision.move_child ( pt8_spr, root2.Fnum[animFrame2].pt8.pz );
		pt8_spr.rotation = root2.Fnum[animFrame2].pt8.pa * (PI/180);
		pt8_up1.position = root2.Fnum[animFrame2].pt8.up1;
		pt8_up2.position = root2.Fnum[animFrame2].pt8.up2;
		pt8_up3.position = root2.Fnum[animFrame2].pt8.up3;
		pt8_md1.position = root2.Fnum[animFrame2].pt8.md1;
		pt8_md2.position = root2.Fnum[animFrame2].pt8.md2;
		pt8_md3.position = root2.Fnum[animFrame2].pt8.md3;
		pt8_dn1.position = root2.Fnum[animFrame2].pt8.dn1;
		pt8_dn2.position = root2.Fnum[animFrame2].pt8.dn2;
		pt8_dn3.position = root2.Fnum[animFrame2].pt8.dn3;
		#//-head
		#pt9_spr.texture.set_current_frame( root2.Fnum[animFrame2].pt9.fm );
		pt9_spr.texture = Head1[ root1.Fnum[animFrame].pt9.fm ];
		
		pt9_spr.position = root2.Fnum[animFrame2].pt9.pos;
		bodyCollision.move_child ( pt9_spr, root2.Fnum[animFrame2].pt9.pz );
		pt9_spr.rotation = root2.Fnum[animFrame2].pt9.pa * (PI/180);
		pt9_up1.position = root2.Fnum[animFrame2].pt9.up1;
		pt9_up2.position = root2.Fnum[animFrame2].pt9.up2;
		pt9_up3.position = root2.Fnum[animFrame2].pt9.up3;
		pt9_md1.position = root2.Fnum[animFrame2].pt9.md1;
		pt9_md2.position = root2.Fnum[animFrame2].pt9.md2;
		pt9_md3.position = root2.Fnum[animFrame2].pt9.md3;
		pt9_dn1.position = root2.Fnum[animFrame2].pt9.dn1;
		pt9_dn2.position = root2.Fnum[animFrame2].pt9.dn2;
		pt9_dn3.position = root2.Fnum[animFrame2].pt9.dn3;
		#//-Right-Hand
		#pt13_spr.texture.set_current_frame( root2.Fnum[animFrame2].pt13.fm );
		pt13_spr.texture = Rhand1[ root1.Fnum[animFrame].pt13.fm ];
		
		pt13_spr.position = root2.Fnum[animFrame2].pt13.pos;
		bodyCollision.move_child ( pt13_spr, root2.Fnum[animFrame2].pt13.pz );
		pt13_spr.rotation = root2.Fnum[animFrame2].pt13.pa * (PI/180);
		pt13_up1.position = root2.Fnum[animFrame2].pt13.up1;
		pt13_up2.position = root2.Fnum[animFrame2].pt13.up2;
		pt13_up3.position = root2.Fnum[animFrame2].pt13.up3;
		pt13_md1.position = root2.Fnum[animFrame2].pt13.md1;
		pt13_md2.position = root2.Fnum[animFrame2].pt13.md2;
		pt13_md3.position = root2.Fnum[animFrame2].pt13.md3;
		pt13_dn1.position = root2.Fnum[animFrame2].pt13.dn1;
		pt13_dn2.position = root2.Fnum[animFrame2].pt13.dn2;
		pt13_dn3.position = root2.Fnum[animFrame2].pt13.dn3;
		#//-Right-armDown
		#pt14_spr.texture.set_current_frame( root2.Fnum[animFrame2].pt14.fm );
		pt14_spr.texture = RarmDn1[ root1.Fnum[animFrame].pt14.fm ];
		
		pt14_spr.position = root2.Fnum[animFrame2].pt14.pos;
		bodyCollision.move_child ( pt14_spr, root2.Fnum[animFrame2].pt14.pz );
		pt14_spr.rotation = root2.Fnum[animFrame2].pt14.pa * (PI/180);
		pt14_up1.position = root2.Fnum[animFrame2].pt14.up1;
		pt14_up2.position = root2.Fnum[animFrame2].pt14.up2;
		pt14_up3.position = root2.Fnum[animFrame2].pt14.up3;
		pt14_md1.position = root2.Fnum[animFrame2].pt14.md1;
		pt14_md2.position = root2.Fnum[animFrame2].pt14.md2;
		pt14_md3.position = root2.Fnum[animFrame2].pt14.md3;
		pt14_dn1.position = root2.Fnum[animFrame2].pt14.dn1;
		pt14_dn2.position = root2.Fnum[animFrame2].pt14.dn2;
		pt14_dn3.position = root2.Fnum[animFrame2].pt14.dn3;
		#//-Right-armUp
		#pt15_spr.texture.set_current_frame( root2.Fnum[animFrame2].pt15.fm );
		pt15_spr.texture = RarmUp1[ root1.Fnum[animFrame].pt15.fm ];
		
		pt15_spr.position = root2.Fnum[animFrame2].pt15.pos;
		bodyCollision.move_child ( pt15_spr, root2.Fnum[animFrame2].pt15.pz );
		pt15_spr.rotation = root2.Fnum[animFrame2].pt15.pa * (PI/180);
		pt15_up1.position = root2.Fnum[animFrame2].pt15.up1;
		pt15_up2.position = root2.Fnum[animFrame2].pt15.up2;
		pt15_up3.position = root2.Fnum[animFrame2].pt15.up3;
		pt15_md1.position = root2.Fnum[animFrame2].pt15.md1;
		pt15_md2.position = root2.Fnum[animFrame2].pt15.md2;
		pt15_md3.position = root2.Fnum[animFrame2].pt15.md3;
		pt15_dn1.position = root2.Fnum[animFrame2].pt15.dn1;
		pt15_dn2.position = root2.Fnum[animFrame2].pt15.dn2;
		pt15_dn3.position = root2.Fnum[animFrame2].pt15.dn3;
		#//-------head-MASK----------------
		#hEx1_spr.texture.set_current_frame( root2.Fnum[animFrame2].hEx.fm );
		hEx1_spr.texture = HeadExt1[ root1.Fnum[animFrame].hEx.fm ];
		
		hEx1_spr.position = root2.Fnum[animFrame2].hEx.pos;
		bodyCollision.move_child ( hEx1_spr, root2.Fnum[animFrame2].hEx.pz );
		hEx1_spr.rotation = root2.Fnum[animFrame2].hEx.pa * (PI/180);
		hEx1_spr.scale = root2.Fnum[animFrame2].hEx.scl;
		#//-------WEAPON----------------
		wp1_spr.position = weapFollow.position + ( root2.Fnum[animFrame2].wp1.pos * bodyCollision.scale );
		wp1_spr.texture = wp1_spr.weapImg[ root1.Fnum[animFrame].wp1.fm ];
		
		move_child ( wp1_spr, viewCon.get_index() + root2.Fnum[animFrame2].wp1.pz );
		wp1_spr.rotation = root2.Fnum[animFrame2].wp1.pa * (PI/180);
		wp1_spr.scale = Vector2(1, 1) +  root2.Fnum[animFrame2].wp1.scl;
	
	#-------------------//---------------//---------------------------------
	#------------------//---LOWER-BODY--//----------------------------------
	#-----------------//---------------//-----------------------------------
	#//-Left-foot
	#pt4_spr.texture.set_current_frame( root1.Fnum[animFrame].pt4.fm );
	pt4_spr.texture = LFoot1[ root1.Fnum[animFrame].pt4.fm ];
	
	pt4_spr.position = root1.Fnum[animFrame].pt4.pos;
	bodyCollision.move_child ( pt4_spr, root1.Fnum[animFrame].pt4.pz );
	pt4_spr.rotation = root1.Fnum[animFrame].pt4.pa * (PI/180);
	pt4_up1.position = root1.Fnum[animFrame].pt4.up1;
	pt4_up2.position = root1.Fnum[animFrame].pt4.up2;
	pt4_up3.position = root1.Fnum[animFrame].pt4.up3;
	pt4_md1.position = root1.Fnum[animFrame].pt4.md1;
	pt4_md2.position = root1.Fnum[animFrame].pt4.md2;
	pt4_md3.position = root1.Fnum[animFrame].pt4.md3;
	pt4_dn1.position = root1.Fnum[animFrame].pt4.dn1;
	pt4_dn2.position = root1.Fnum[animFrame].pt4.dn2;
	pt4_dn3.position = root1.Fnum[animFrame].pt4.dn3;
	#//-Left-legDown
	#pt5_spr.texture.set_current_frame( root1.Fnum[animFrame].pt5.fm );
	pt5_spr.texture = LlegDn1[ root1.Fnum[animFrame].pt5.fm ];
	
	pt5_spr.position = root1.Fnum[animFrame].pt5.pos;
	bodyCollision.move_child ( pt5_spr, root1.Fnum[animFrame].pt5.pz );
	pt5_spr.rotation = root1.Fnum[animFrame].pt5.pa * (PI/180);
	pt5_up1.position = root1.Fnum[animFrame].pt5.up1;
	pt5_up2.position = root1.Fnum[animFrame].pt5.up2;
	pt5_up3.position = root1.Fnum[animFrame].pt5.up3;
	pt5_md1.position = root1.Fnum[animFrame].pt5.md1;
	pt5_md2.position = root1.Fnum[animFrame].pt5.md2;
	pt5_md3.position = root1.Fnum[animFrame].pt5.md3;
	pt5_dn1.position = root1.Fnum[animFrame].pt5.dn1;
	pt5_dn2.position = root1.Fnum[animFrame].pt5.dn2;
	pt5_dn3.position = root1.Fnum[animFrame].pt5.dn3;
	#//-Left-legUp
	#pt6_spr.texture.set_current_frame( root1.Fnum[animFrame].pt6.fm );
	pt6_spr.texture = LlegUp1[ root1.Fnum[animFrame].pt6.fm ];
	
	pt6_spr.position = root1.Fnum[animFrame].pt6.pos;
	bodyCollision.move_child ( pt6_spr, root1.Fnum[animFrame].pt6.pz );
	pt6_spr.rotation = root1.Fnum[animFrame].pt6.pa * (PI/180);
	pt6_up1.position = root1.Fnum[animFrame].pt6.up1;
	pt6_up2.position = root1.Fnum[animFrame].pt6.up2;
	pt6_up3.position = root1.Fnum[animFrame].pt6.up3;
	pt6_md1.position = root1.Fnum[animFrame].pt6.md1;
	pt6_md2.position = root1.Fnum[animFrame].pt6.md2;
	pt6_md3.position = root1.Fnum[animFrame].pt6.md3;
	pt6_dn1.position = root1.Fnum[animFrame].pt6.dn1;
	pt6_dn2.position = root1.Fnum[animFrame].pt6.dn2;
	pt6_dn3.position = root1.Fnum[animFrame].pt6.dn3;
	#//-waist
	#pt7_spr.texture.set_current_frame( root1.Fnum[animFrame].pt7.fm );
	pt7_spr.texture = Waist1[ root1.Fnum[animFrame].pt7.fm ];
	
	pt7_spr.position = root1.Fnum[animFrame].pt7.pos;
	bodyCollision.move_child ( pt7_spr, root1.Fnum[animFrame].pt7.pz );
	pt7_spr.rotation = root1.Fnum[animFrame].pt7.pa * (PI/180);
	pt7_up1.position = root1.Fnum[animFrame].pt7.up1;
	pt7_up2.position = root1.Fnum[animFrame].pt7.up2;
	pt7_up3.position = root1.Fnum[animFrame].pt7.up3;
	pt7_md1.position = root1.Fnum[animFrame].pt7.md1;
	pt7_md2.position = root1.Fnum[animFrame].pt7.md2;
	pt7_md3.position = root1.Fnum[animFrame].pt7.md3;
	pt7_dn1.position = root1.Fnum[animFrame].pt7.dn1;
	pt7_dn2.position = root1.Fnum[animFrame].pt7.dn2;
	pt7_dn3.position = root1.Fnum[animFrame].pt7.dn3;
	#//-Right-foot
	#pt10_spr.texture.set_current_frame( root1.Fnum[animFrame].pt10.fm );
	pt10_spr.texture = RFoot1[ root1.Fnum[animFrame].pt10.fm ];
	
	pt10_spr.position = root1.Fnum[animFrame].pt10.pos;
	bodyCollision.move_child ( pt10_spr, root1.Fnum[animFrame].pt10.pz );
	pt10_spr.rotation = root1.Fnum[animFrame].pt10.pa * (PI/180);
	pt10_up1.position = root1.Fnum[animFrame].pt10.up1;
	pt10_up2.position = root1.Fnum[animFrame].pt10.up2;
	pt10_up3.position = root1.Fnum[animFrame].pt10.up3;
	pt10_md1.position = root1.Fnum[animFrame].pt10.md1;
	pt10_md2.position = root1.Fnum[animFrame].pt10.md2;
	pt10_md3.position = root1.Fnum[animFrame].pt10.md3;
	pt10_dn1.position = root1.Fnum[animFrame].pt10.dn1;
	pt10_dn2.position = root1.Fnum[animFrame].pt10.dn2;
	pt10_dn3.position = root1.Fnum[animFrame].pt10.dn3;
	#//-Right-legDown
	#pt11_spr.texture.set_current_frame( root1.Fnum[animFrame].pt11.fm );
	pt11_spr.texture = RLegDn1[ root1.Fnum[animFrame].pt11.fm ];
	
	pt11_spr.position = root1.Fnum[animFrame].pt11.pos;
	bodyCollision.move_child ( pt11_spr, root1.Fnum[animFrame].pt11.pz );
	pt11_spr.rotation = root1.Fnum[animFrame].pt11.pa * (PI/180);
	pt11_up1.position = root1.Fnum[animFrame].pt11.up1;
	pt11_up2.position = root1.Fnum[animFrame].pt11.up2;
	pt11_up3.position = root1.Fnum[animFrame].pt11.up3;
	pt11_md1.position = root1.Fnum[animFrame].pt11.md1;
	pt11_md2.position = root1.Fnum[animFrame].pt11.md2;
	pt11_md3.position = root1.Fnum[animFrame].pt11.md3;
	pt11_dn1.position = root1.Fnum[animFrame].pt11.dn1;
	pt11_dn2.position = root1.Fnum[animFrame].pt11.dn2;
	pt11_dn3.position = root1.Fnum[animFrame].pt11.dn3;
	#//-Right-legUp
	#pt12_spr.texture.set_current_frame( root1.Fnum[animFrame].pt12.fm );
	pt12_spr.texture = RLegUp1[ root1.Fnum[animFrame].pt12.fm ];
	
	pt12_spr.position = root1.Fnum[animFrame].pt12.pos;
	bodyCollision.move_child ( pt12_spr, root1.Fnum[animFrame].pt12.pz );
	pt12_spr.rotation = root1.Fnum[animFrame].pt12.pa * (PI/180);
	pt12_up1.position = root1.Fnum[animFrame].pt12.up1;
	pt12_up2.position = root1.Fnum[animFrame].pt12.up2;
	pt12_up3.position = root1.Fnum[animFrame].pt12.up3;
	pt12_md1.position = root1.Fnum[animFrame].pt12.md1;
	pt12_md2.position = root1.Fnum[animFrame].pt12.md2;
	pt12_md3.position = root1.Fnum[animFrame].pt12.md3;
	pt12_dn1.position = root1.Fnum[animFrame].pt12.dn1;
	pt12_dn2.position = root1.Fnum[animFrame].pt12.dn2;
	pt12_dn3.position = root1.Fnum[animFrame].pt12.dn3;
	



func _physics_process(_delta: float) -> void:
	
	
	if nextFrame  || nextFrame2:
		_ptSimplePath();
	
	
	#_delayGo(delta);
	#_delayGoRoot2(delta);
	
	if ( animDelay.time_left >= 0.0 ):
		nextFrame = false;
	if ( animDelay2.time_left >= 0.0 ):
		nextFrame2 = false;
	
	

That code looks scary. Think about reorganizing your data structures so you don’t need to write this much repetitive code. At least use loops to avoid typing the same thing over and over.

I know… The max number of enemies i can have on screen is about 20 or 30, after that the level starts to lag and the fps drop to about 10, or 15.

The problem is i dont know how to do this…

The torso polygon2D has an array with 4 textures…

pt8_spr.texture = Torso1[ root1.Fnum[animFrame].pt8.fm ];

Even if in frame 0 and frame 1 they have the same texture.. Godot is still going to replace the texture with a new texture… the same thing happens for all the other values, position, etc…

I managed to put more than 100 enemies on screen by using a visibleOnScreenNotifier2D


func _physics_process(_delta: float) -> void:
	
	
	if  is_on_screen == true && ( nextFrame  || nextFrame2 ):
		_ptSimplePath();




func _on_visible_on_screen_notifier_2d_screen_entered() -> void:
	is_on_screen = true;
	viewCon.visible = true;
	weapFollow.visible = true;



func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
	is_on_screen = false;
	viewCon.visible = false;
	weapFollow.visible = false;

but its a cheap way of doing it, if more than 30 enemies are on alert and chasing the player the FPS drops to 10 / 15 or lower

If i could make the “animation / _ptSimplePath()” to only update the values that are diferent from the previous frame maybe it would be fine, but i just dont know how to do it,

i dont see how its possible without making the code even worse with a bunch of if’s..if’s…if’s…if this value != previous value on top of each line of code..

I dont know if the godot animator is better than this…

Your performance issue might be explained by this recent official blog post

Your performance issue might be explained by this recent official blog post

its the reason why i made the post

But in that situation the godot animator is being used and a timeLine interpolating values its even worse than a frame by frame animation, but the godot animator seems to be faster, because is not overwriting already pre existing values.

Yeah… when someone fixes of a big pile of --------, someone else always shows up with an even bigger pile of ------------- has a reward :grin:

Your performance issue might be explained by this recent official blog post

https://github.com/godotengine/godot/issues/115476

in the mrp “goatMRP.zip” with the 120 goats on screen i get 33 fps

in my game with 120 enemies on screen just playing a walking animation i get 6 to 7 FPS