Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Player_0 |
Hello, my error is that I have a scene with its respective script that fulfills the bullet function and I have another scene with its respective player script, instance and I create the bullet in the player, until there everything works perfectly, the bullet is It is moving thanks to the function move_and_collide (), taking into account that the bullet is always in motion, when the two bodies collide the player and the bullet, it only works when it collides head-on, but if the player collides with the bullet from behind it not detects the collision.
If I was not very clear tell me to clarify it specifically
My code
bullet:
func _muerte_por_colision() -> void:
if colision.collider.is_in_group("players"):
Singleton.emit_signal("death", colision.collider)
queue_free()
elif colision.collider.is_in_group("proyectil"):
pass
#queue_free()
else:
movimiento = movimiento.bounce(colision.normal)
alt = false
func _physics_process(delta):
if colision:
print(colision, "se activo")
_muerte_por_colision()
if alt == true:
movimiento = Vector2(4,0).rotated(rotation)
colision = move_and_collide(movimiento)
else:
colision = move_and_collide(movimiento)
count += delta
if count > 16:
queue_free()
Player:
if municion > 0:
var bala = Singleton.BALA.instance()
get_parent().call_deferred("add_child", bala)
bala.position = get_node("Core/salida").global_position
bala.rotation_degrees = $Core.global_rotation_degrees
municion -= 1
Check your layer and mask if it is right
Mrpaolosarino | 2021-04-01 13:06
yep i do and it is right
Player_0 | 2021-04-01 13:11