+1 vote

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: http://boxdox-bb.dantarion.com/#/viewer/bbcf_200/jb/NmlAtkAIR5C/20 . 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?

Call method track:
Commercial Photography

Here is the code sample:

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

Here is minimum example project:

Any suggestions are appreciated. Thank you very much for spending your precious time!

in Engine by (21 points)
recategorized by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.