Hello! I am developing a game in wich you'll have a sword. The plan is that you can rotate the sword around (kinda like in "Nuclear Throne" but with a sword) Your damage would be highly affected by the speed of the sword you're wielding. The question is how to actually calculate the speed?? Simply calculating the magnitude isn't enough because i use two nodes to rotate the weapon around.
Here's a pic:
Here Is my code That i Use currently:
onready var speed = 0
onready var distance = self.position.distance_to( get_parent().get_parent().position )
onready var pre_distance = distance
distance = self.global_position.distance_to(
speed = abs(pre_distance - distance)
# Update prev_magnitude per every 0.005 seconds
pre_distance = distance
I know that it is terrible code. It's not even global, as you can see I made it, so it's relative to the parent. I am only learning so don't judge me. XD
Ps: Thanks for the answer.