Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | humble-coder |
I’m trying to replicate hit-box system that is utilized in some of fighting games. Take a look here for example for a hit-box viewer tool: boxdox.bb . As you can see during the course of the animation hit-boxes are added or removed dynamically. Currently I’m using tool script that I call from a Call Method Track
in the AnimationPlayer
this script adds a CollisionShape2d
during the animation, and while this approach is working perfectly fine when i build game, this approach is not working when I’m trying to use it in an editor. Is it possible to somehow call the script in AnimationPlayer
while in editor? And if not what would you suggest as an alternative? Maybe there is an open source project to learn from on how to create this type of dynamic collision system tool in Godot?
Here is the code sample:
tool
extends Area2D
func add_rectangle_shape(x, y, width, height):
print_debug(x, y, width, height)
var collision = CollisionShape2D.new()
var shape = RectangleShape2D.new()
shape.extents = Vector2(width, height)
collision.shape = shape
add_child(collision)
Here is minimum example project:
https://www.dropbox.com/s/a3jj5ejn6shy3q4/collizion-shapes.zip?dl=0
Any suggestions are appreciated. Thank you very much for spending your precious time!