Unable to deform mesh with SkeletonIK

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sxkod

Morning all

I am stuck at making IK work through script. Hoping for some help. I will include the script and the order of nodes below.

			-FPS Mesh

I tried the https://www.youtube.com/watch?v=TfAO2W6lO8E by RandomMomentania and Skeleton Inverse Kinematic - Godot 3.1 by Andrea Catania.

I can make the mesh deform by manually moving the target in the editor. However - I am hoping to make it happen through script so that I can either move the target in the script
or change the target_node of IK during runtime, to help with picking a different weapon and having the hands moving to new holding location based on the weapon. However, when I try to change the target node or when I move the current target_node either by changing global_transform or global_transform.origin - no mesh deform happens. I can still play the animation and that works as expected.

What am I doing wrong?

extends Spatial

onready var iktarg=$Armature/Skeleton/target_1

func _input(event):
	if Input.is_key_pressed(KEY_UP):
	elif Input.is_key_pressed(KEY_DOWN):

	if Input.is_key_pressed(KEY_SPACE):

Thanks all

Not to answer my own question but the SkeletonIK needs to be started and then run when modified in code. At least that helped my situation. In the following code, I have Skeleton with SkeletonIK and two spatials P1 and P2 as it’s children.
Hope this helps someone

extends Spatial

var cur=1

func _ready():

func _input(event):
	if Input.is_key_pressed(KEY_SPACE) and not event.is_echo():
		if cur==1:

sxkod | 2020-10-07 14:56