|Attention||Topic was automatically imported from the old Question2Answer platform.|
So basically the collisions are kinda f*cked for some reason and don’t work half the time and as far as I could see the only pattern is that the first couple bullets always worked and after that it was(as far as i could see more up to chance) random but it did work more often when you moved up and down. I have tried removing, code double checked everything asked on discord and nothing worked. I think its not associated with the script but something else(maybe even an engine bug) I uploaded the project to MegaUp. THE LINK: https://megaup.net/Vxip/Space_shooter.rar. But in case its just a matter with the code and I am stupid here it is:
extends KinematicBody2D export var speed = 0.0 func _physics_process(delta): move_and_slide(Vector2(speed, 0)) for i in get_slide_count(): var collision = get_slide_collision(i) if collision.collider.get_collision_layer_bit(2): collision.collider.queue_free() queue_free() func _on_bomb_timeout(): queue_free()
extends KinematicBody2D export var HP = 0 func _process(delta): move_and_slide(Vector2.ZERO) for i in get_slide_count(): var collision = get_slide_collision(i) HP -= 1 collision.collider.queue_free() if HP <= 0: queue_free()
Maybe it has to do with the callback functions that are being used? The bullet script uses
_physics_process() while the enemy script uses
_process(). Since collision detection is calculated in the
_physics_process() function, change the callback function in the enemy script to
Ertain | 2021-02-13 19:59
Sadly it didnt work. But I doubt this would do anything since they are not associated.
lotos | 2021-02-13 20:04
I’m not sure I’m understanding your question, but it seems like you need to enable continuous collision detection. This enabled more precise collisions at the cost of a bit of performance.
andersmmg | 2021-02-14 00:32