0 votes

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:

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!

asked Apr 17, 2019 in Engine by humble-coder (20 points)
recategorized Apr 17, 2019 by humble-coder

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.