Topic was automatically imported from the old Question2Answer platform.
Asked By
RockyXDeadman
Hi i am trying to program my enemy using animation tree as its a 2.5d enemy .
i have an attack radius area2d rectangle and i have connected signals for it to detect the player body but when the player enter the body the enemy only hits him once and doesnt keep attacking. is there any way to fix this?
Hi,
I did a similar thing with a missile launcher shooting at a space ship when it entered an area2d, like this:
In func _on_Radar_body_entered(body: Node) -> void: when the ship enters I set a bool to true to say it can be shot at.
In func _on_Radar_body_exited(body: Node) -> void: when the ship leaves I set the bool to false, so it can’t be shot at.
Then in the _process function, if the bool is true, shoot the ship.
Hi i tried but it did not work can you help me out? here is my code:
func attack_state(delta):
animationstate.travel("attack")
velocity = velocity.move_toward(Vector2.ZERO, friction * delta)
func _on_attackradius_body_entered(body):
state = attack #this goes to the attack state above
func _on_attackradius_body_exited(body):
state = walk
RockyXDeadman | 2020-07-15 07:19
happy to help.
Any chance you could upload your project (or a cut down version with just the scene/s that have the issue in them) ?