Sprite behaving strangely

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Harshitsoam

Hi I am facing a very strange problem enemy of my game which is kinematicbody2d and it is spawned at random y coordinates and comes down on the screen it code for coming down is position.y+=EnemySpeed.green_enemy_speed Here enemy speed is a int variable which is assigned to 2 and increments over time maximum to 10 the problem is when enemy is coming down from the screen it does not refresh real-time here is a video of showing what exactly the problem is -

I tried changing movement from incrementing position.y to move_and_collide but problem remains same please help me

:bust_in_silhouette: Reply From: Inces

I don’t really see the lag.
But You didn’t apply delta in this movement calculation, so your enemy speed is dependant on your CPU speed now.

You should do :

position.y+=EnemySpeed.green_enemy_speed * delta

However your speed needs to be much larger than 2 now

No bro it is not working I tried increasing enemy speed upto 100000 but it is very slow

Harshitsoam | 2022-07-31 12:47

There must be problem with updating your speed. It should work with value around 10-100. Try to input 50 manually, without using your EnemySpeed reference

Inces | 2022-08-01 14:52