@TwistedTwigleg First of all thank you for the awnser and the welcoming :)
Im pretty new to godot and programming, just learing it for now about for 3 weeks.
I have a simple code with several .tscn
1 is for Hitbox.tscn
1 is for Hurtbox.tscn
1 is for Player.tscn
1 is for Enemy.tscn
When Player shoot bullet, I am Detecting by the attached hurtbox to enemy is hitted
Hittbox.tscn is a a Aread2d with a collisionshape2d:
extends Area2D
export(int) var damage = 1
func _on_Hitbox_area_entered(hurtbox):
hurtbox.emit_signal("hit", damage)
Hurtbox is aswell a Aread2d with a collisionshape2d
extends Area2D
# warning-ignore:unused_signal
signal hit(damage)
in the enemy i have bouth hitbox and hurtbox attached.
So i can do this func
extends KinematicBody2D
func _on_Hurtbox_hit(damage):
stats.health -= damage
I am working with preset hitbox and hurtbox, aswell with a Stats preset, so i can just drag and drop these into the kinematicbody when i create a new enemy.
My problem is now, i dont know how to read out the position from the player to have the position from where he is shooting or know the direction the bullet that enters the hitbox. So i can knockback in the other direction.
I hope there is a simple solution for that.
Best Regards