Browse Source

Merge pull request #330 from aaronfranke/update-ik

Update and optimize 3D IK Demo
Aaron Franke 5 years ago
parent
commit
50d5a118c9

+ 180 - 196
3d/ik/addons/sade/ik_fabrik.gd

@@ -1,19 +1,21 @@
 tool
 tool
 extends Spatial
 extends Spatial
+# A FABRIK IK chain with a middle joint helper.
 
 
-"""
-A FABRIK IK chain with a middle joint helper.
-"""
+# The delta/tolerance for the bone chain (how do the bones need to be before it is considered satisfactory)
+const CHAIN_TOLERANCE = 0.01
+# The amount of interations the bone chain will go through in an attempt to get to the target position
+const CHAIN_MAX_ITER = 10
 
 
-export (NodePath) var skeleton_path setget _set_skeleton_path
-export (PoolStringArray) var bones_in_chain setget _set_bone_chain_bones
-export (PoolRealArray) var bones_in_chain_lengths setget _set_bone_chain_lengths
+export(NodePath) var skeleton_path setget _set_skeleton_path
+export(PoolStringArray) var bones_in_chain setget _set_bone_chain_bones
+export(PoolRealArray) var bones_in_chain_lengths setget _set_bone_chain_lengths
 
 
-export (int, "_process", "_physics_process", "_notification", "none") var update_mode = 0 setget _set_update_mode
+export(int, "_process", "_physics_process", "_notification", "none") var update_mode = 0 setget _set_update_mode
 
 
-var target = null
+var target: Spatial = null
 
 
-var skeleton
+var skeleton: Skeleton
 
 
 # A dictionary holding all of the bone IDs (from the skeleton) and a dictionary holding
 # A dictionary holding all of the bone IDs (from the skeleton) and a dictionary holding
 # all of the bone helper nodes
 # all of the bone helper nodes
@@ -21,23 +23,19 @@ var bone_IDs = {}
 var bone_nodes = {}
 var bone_nodes = {}
 
 
 # The position of the origin
 # The position of the origin
-var chain_origin = null
+var chain_origin = Vector3()
 # The combined length of every bone in the bone chain
 # The combined length of every bone in the bone chain
-var total_length = null
-# The delta/tolerance for the bone chain (how do the bones need to be before it is considered satisfactory)
-const CHAIN_TOLERANCE = 0.01
-# The amount of interations the bone chain will go through in an attempt to get to the target position
-const CHAIN_MAX_ITER = 10
+var total_length = INF
 # The amount of iterations we've been through, and whether or not we want to limit our solver to CHAIN_MAX_ITER
 # The amount of iterations we've been through, and whether or not we want to limit our solver to CHAIN_MAX_ITER
 # amounts of interations.
 # amounts of interations.
-export (int) var chain_iterations = 0
-export (bool) var limit_chain_iterations = true
+export(int) var chain_iterations = 0
+export(bool) var limit_chain_iterations = true
 # Should we reset chain_iterations on movement during our update method?
 # Should we reset chain_iterations on movement during our update method?
-export (bool) var reset_iterations_on_update = false
+export(bool) var reset_iterations_on_update = false
 
 
 # A boolean to track whether or not we want to move the middle joint towards middle joint target.
 # A boolean to track whether or not we want to move the middle joint towards middle joint target.
-export (bool) var use_middle_joint_target = false
-var middle_joint_target = null
+export(bool) var use_middle_joint_target = false
+var middle_joint_target: Spatial = null
 
 
 # Have we called _set_skeleton_path or not already. Due to some issues using exported NodePaths,
 # Have we called _set_skeleton_path or not already. Due to some issues using exported NodePaths,
 # we need to ignore the first _set_skeleton_path call.
 # we need to ignore the first _set_skeleton_path call.
@@ -46,9 +44,9 @@ var first_call = true
 # A boolean to track whether or not we want to print debug messages
 # A boolean to track whether or not we want to print debug messages
 var debug_messages = false
 var debug_messages = false
 
 
+
 func _ready():
 func _ready():
-	
-	if (target == null):
+	if target == null:
 		# NOTE: you HAVE to have a node called target as a child of this node!
 		# NOTE: you HAVE to have a node called target as a child of this node!
 		# so we create one if one doesn't already exist
 		# so we create one if one doesn't already exist
 		if has_node("target") == false:
 		if has_node("target") == false:
@@ -93,138 +91,19 @@ func _ready():
 	_set_update_mode(update_mode)
 	_set_update_mode(update_mode)
 
 
 
 
-func _make_editor_sphere_at_node(node, color):
-	# So we can see the target in the editor, let's create a mesh instance,
-	# Add it as our child, and name it
-	var indicator = MeshInstance.new()
-	node.add_child(indicator)
-	indicator.name = "(EditorOnly) Visual indicator"
-
-	# We need to make a mesh for the mesh instance.
-	# The code below makes a small sphere mesh
-	var indicator_mesh = SphereMesh.new()
-	indicator_mesh.radius = 0.1
-	indicator_mesh.height = 0.2
-	indicator_mesh.radial_segments = 8
-	indicator_mesh.rings = 4
-
-	# The mesh needs a material (unless we want to use the defualt one).
-	# Let's create a material and use the EditorGizmoTexture to texture it.
-	var indicator_material = SpatialMaterial.new()
-	indicator_material.flags_unshaded = true
-	indicator_material.albedo_texture = preload("editor_gizmo_texture.png")
-	indicator_material.albedo_color = color
-	indicator_mesh.material = indicator_material
-	indicator.mesh = indicator_mesh
-
-
-############# SETGET FUNCTIONS #############
-
-
-func _set_update_mode(new_value):
-	update_mode = new_value
-	
-	set_process(false)
-	set_physics_process(false)
-	set_notify_transform(false)
-	
-	if update_mode == 0:
-		set_process(true)
-	elif update_mode == 1:
-		set_process(true)
-	elif update_mode == 2:
-		set_notify_transform(true)
-	else:
-		if debug_messages == true:
-			print (name, " - IK_FABRIK: Unknown update mode. NOT updating skeleton")
-		return
-
-
-func _set_skeleton_path(new_value):
-	
-	# Because get_node doesn't work in the first call, we just want to assign instead
-	if first_call == true:
-		skeleton_path = new_value
-		return
-	
-	skeleton_path = new_value
-	
-	if skeleton_path == null:
-		if debug_messages == true:
-			print (name, " - IK_FABRIK: No Nodepath selected for skeleton_path!")
-		return
-	
-	var temp = get_node(skeleton_path)
-	if temp != null:
-		# If it has the method "get_bone_global_pose" it is likely a Skeleton
-		if temp.has_method("get_bone_global_pose") == true:
-			skeleton = temp
-			bone_IDs = {}
-			
-			# (Delete all of the old bone nodes and) Make all of the bone nodes for each bone in the IK chain
-			_make_bone_nodes()
-			
-			if debug_messages == true:
-				print (name, " - IK_FABRIK: Attached to a new skeleton")
-		# If not, then it's (likely) not a Skeleton node
-		else:
-			skeleton = null
-			if debug_messages == true:
-				print (name, " - IK_FABRIK: skeleton_path does not point to a skeleton!")
-	else:
-		if debug_messages == true:
-			print (name, " - IK_FABRIK: No Nodepath selected for skeleton_path!")
-
-############# OTHER (NON IK SOLVER RELATED) FUNCTIONS #############
-
-
-func _make_bone_nodes():
-	# Remove all of the old bone nodes
-	# TODO: (not a huge concern, as these can be removed in the editor)
-	
-	for bone in range(0, bones_in_chain.size()):
-		
-		var bone_name = bones_in_chain[bone]
-		if has_node(bone_name) == false:
-			var new_node = Spatial.new()
-			bone_nodes[bone] = new_node
-			add_child(bone_nodes[bone])
-			
-			if Engine.editor_hint == true:
-				if get_tree() != null:
-					if get_tree().edited_scene_root != null:
-						bone_nodes[bone].set_owner(get_tree().edited_scene_root)
-			
-			bone_nodes[bone].name = bone_name
-			
-		else:
-			bone_nodes[bone] = get_node(bone_name)
-		
-		# If we are in the editor, we want to make a sphere at this node
-		if Engine.editor_hint == true:
-			_make_editor_sphere_at_node(bone_nodes[bone], Color(0.65, 0, 1, 1))
-
-
-func _set_bone_chain_bones(new_value):
-	bones_in_chain = new_value
-	
-	_make_bone_nodes()
-
-func _set_bone_chain_lengths(new_value):
-	bones_in_chain_lengths = new_value
-	total_length = null
-
-
 # Various upate methods
 # Various upate methods
-# ---------------------
-func _process(delta):
+func _process(_delta):
 	if reset_iterations_on_update == true:
 	if reset_iterations_on_update == true:
 		chain_iterations = 0
 		chain_iterations = 0
 	update_skeleton()
 	update_skeleton()
-func _physics_process(delta):
+
+
+func _physics_process(_delta):
 	if reset_iterations_on_update == true:
 	if reset_iterations_on_update == true:
 		chain_iterations = 0
 		chain_iterations = 0
 	update_skeleton()
 	update_skeleton()
+
+
 func _notification(what):
 func _notification(what):
 	if what == NOTIFICATION_TRANSFORM_CHANGED:
 	if what == NOTIFICATION_TRANSFORM_CHANGED:
 		if reset_iterations_on_update == true:
 		if reset_iterations_on_update == true:
@@ -235,7 +114,6 @@ func _notification(what):
 ############# IK SOLVER RELATED FUNCTIONS #############
 ############# IK SOLVER RELATED FUNCTIONS #############
 
 
 func update_skeleton():
 func update_skeleton():
-	
 	#### ERROR CHECKING conditions
 	#### ERROR CHECKING conditions
 	if first_call == true:
 	if first_call == true:
 		_set_skeleton_path(skeleton_path)
 		_set_skeleton_path(skeleton_path)
@@ -248,16 +126,16 @@ func update_skeleton():
 	
 	
 	if bones_in_chain == null:
 	if bones_in_chain == null:
 		if debug_messages == true:
 		if debug_messages == true:
-			print (name, " - IK_FABRIK: No Bones in IK chain defined!")
+			printerr(name, " - IK_FABRIK: No Bones in IK chain defined!")
 		return
 		return
 	if bones_in_chain_lengths == null:
 	if bones_in_chain_lengths == null:
 		if debug_messages == true:
 		if debug_messages == true:
-			print (name, " - IK_FABRIK: No Bone lengths in IK chain defined!")
+			printerr(name, " - IK_FABRIK: No Bone lengths in IK chain defined!")
 		return
 		return
 	
 	
 	if bones_in_chain.size() != bones_in_chain_lengths.size():
 	if bones_in_chain.size() != bones_in_chain_lengths.size():
 		if debug_messages == true:
 		if debug_messages == true:
-			print (name, " - IK_FABRIK: bones_in_chain and bones_in_chain_lengths!")
+			printerr(name, " - IK_FABRIK: bones_in_chain and bones_in_chain_lengths!")
 		return
 		return
 	
 	
 	################################
 	################################
@@ -272,24 +150,21 @@ func update_skeleton():
 			bone_nodes[i].global_transform = get_bone_transform(i)
 			bone_nodes[i].global_transform = get_bone_transform(i)
 			# If this is not the last bone in the bone chain, make it look at the next bone in the bone chain
 			# If this is not the last bone in the bone chain, make it look at the next bone in the bone chain
 			if i < bone_IDs.size()-1:
 			if i < bone_IDs.size()-1:
-				bone_nodes[i].look_at(get_bone_transform(i+1).origin + skeleton.global_transform.origin, Vector3(0, 1, 0))
+				bone_nodes[i].look_at(get_bone_transform(i+1).origin + skeleton.global_transform.origin, Vector3.UP)
 			
 			
 			i += 1
 			i += 1
 	
 	
 	# Set the total length of the bone chain, if it is not already set
 	# Set the total length of the bone chain, if it is not already set
-	if total_length == null:
+	if total_length == INF:
 		total_length = 0
 		total_length = 0
 		for bone_length in bones_in_chain_lengths:
 		for bone_length in bones_in_chain_lengths:
 			total_length += bone_length
 			total_length += bone_length
 	
 	
-	
 	# Solve the bone chain
 	# Solve the bone chain
 	solve_chain()
 	solve_chain()
 
 
 
 
-
 func solve_chain():
 func solve_chain():
-	
 	# If we have reached our max chain iteration, and we are limiting ourselves, then return.
 	# If we have reached our max chain iteration, and we are limiting ourselves, then return.
 	# Otherwise set chain_iterations to zero (so we constantly update)
 	# Otherwise set chain_iterations to zero (so we constantly update)
 	if chain_iterations >= CHAIN_MAX_ITER and limit_chain_iterations == true:
 	if chain_iterations >= CHAIN_MAX_ITER and limit_chain_iterations == true:
@@ -298,11 +173,10 @@ func solve_chain():
 		chain_iterations = 0
 		chain_iterations = 0
 	
 	
 	# Update the origin with the current bone's origin
 	# Update the origin with the current bone's origin
-	chain_origin = get_bone_transform(0)
+	chain_origin = get_bone_transform(0).origin
 	
 	
 	# Get the direction of the final bone by using the next to last bone if there is more than 2 bones.
 	# Get the direction of the final bone by using the next to last bone if there is more than 2 bones.
 	# If there are only 2 bones, we use the target's forward Z vector instead (not ideal, but it works fairly well)
 	# If there are only 2 bones, we use the target's forward Z vector instead (not ideal, but it works fairly well)
-	#var dir = -target.global_transform.basis.z.normalized()
 	var dir
 	var dir
 	if bone_nodes.size() > 2:
 	if bone_nodes.size() > 2:
 		dir = bone_nodes[bone_nodes.size()-2].global_transform.basis.z.normalized()
 		dir = bone_nodes[bone_nodes.size()-2].global_transform.basis.z.normalized()
@@ -319,26 +193,26 @@ func solve_chain():
 			bone_nodes[bone_nodes.size()/2].global_transform.origin = middle_point_pos.origin
 			bone_nodes[bone_nodes.size()/2].global_transform.origin = middle_point_pos.origin
 	
 	
 	# Get the distance from the origin to the target
 	# Get the distance from the origin to the target
-	var distance = (chain_origin.origin - target_pos).length()
+	var distance = (chain_origin - target_pos).length()
 	
 	
 	# If the distance is farther than our total reach, the target cannot be reached.
 	# If the distance is farther than our total reach, the target cannot be reached.
 	# Make the bone chain a straight line pointing towards the target
 	# Make the bone chain a straight line pointing towards the target
 	if distance > total_length:
 	if distance > total_length:
 		for i in range (0, bones_in_chain.size()):
 		for i in range (0, bones_in_chain.size()):
 			# Create a direct line to target and make this bone travel down that line
 			# Create a direct line to target and make this bone travel down that line
-			
-			var r = (target_pos - bone_nodes[i].global_transform.origin).length()
+			var curr_origin = bone_nodes[i].global_transform.origin
+			var r =(target_pos - curr_origin).length()
 			var l = bones_in_chain_lengths[i] / r
 			var l = bones_in_chain_lengths[i] / r
 			
 			
 			# Find new join position
 			# Find new join position
-			var new_pos = (1-l) * bone_nodes[i].global_transform.origin + l * target_pos
+			var new_pos = curr_origin.linear_interpolate(target_pos, l)
 			
 			
 			# Apply it to the bone node
 			# Apply it to the bone node
-			bone_nodes[i].look_at(new_pos, Vector3(0, 1, 0))
+			bone_nodes[i].look_at(new_pos, Vector3.UP)
 			bone_nodes[i].global_transform.origin = new_pos
 			bone_nodes[i].global_transform.origin = new_pos
 		
 		
 		# Apply the rotation to the first node in the bone chain, making it look at the next bone in the bone chain
 		# Apply the rotation to the first node in the bone chain, making it look at the next bone in the bone chain
-		bone_nodes[0].look_at(bone_nodes[1].global_transform.origin, Vector3(0, 1, 0))
+		bone_nodes[0].look_at(bone_nodes[1].global_transform.origin, Vector3.UP)
 	
 	
 	# If the distance is NOT farther than our total reach, the target can be reached.
 	# If the distance is NOT farther than our total reach, the target can be reached.
 	else:
 	else:
@@ -361,20 +235,19 @@ func solve_chain():
 				break
 				break
 	
 	
 	# Reset the bone node transforms to the skeleton bone transforms
 	# Reset the bone node transforms to the skeleton bone transforms
-	#if (constrained == false): # Resetting seems to break bone constraints...
+	#if constrained == false: # Resetting seems to break bone constraints...
 	for i in range(0, bone_nodes.size()):
 	for i in range(0, bone_nodes.size()):
 		var reset_bone_trans = get_bone_transform(i)
 		var reset_bone_trans = get_bone_transform(i)
 		bone_nodes[i].global_transform = reset_bone_trans
 		bone_nodes[i].global_transform = reset_bone_trans
 
 
 
 
+# Backward reaching pass
 func chain_backward():
 func chain_backward():
-	# Backward reaching pass
-	
 	# Get the direction of the final bone by using the next to last bone if there is more than 2 bones.
 	# Get the direction of the final bone by using the next to last bone if there is more than 2 bones.
 	# If there are only 2 bones, we use the target's forward Z vector instead (not ideal, but it works fairly well)
 	# If there are only 2 bones, we use the target's forward Z vector instead (not ideal, but it works fairly well)
 	var dir
 	var dir
 	if bone_nodes.size() > 2:
 	if bone_nodes.size() > 2:
-		dir = bone_nodes[bone_nodes.size()-2].global_transform.basis.z.normalized()
+		dir = bone_nodes[bone_nodes.size() - 2].global_transform.basis.z.normalized()
 	else:
 	else:
 		dir = -target.global_transform.basis.z.normalized()
 		dir = -target.global_transform.basis.z.normalized()
 	
 	
@@ -384,51 +257,42 @@ func chain_backward():
 	# For all of the other bones, move them towards the target
 	# For all of the other bones, move them towards the target
 	var i = bones_in_chain.size() - 1
 	var i = bones_in_chain.size() - 1
 	while i >= 1:
 	while i >= 1:
-		
+		var prev_origin = bone_nodes[i].global_transform.origin
 		i -= 1
 		i -= 1
+		var curr_origin = bone_nodes[i].global_transform.origin
 		
 		
-		var r = bone_nodes[i+1].global_transform.origin - bone_nodes[i].global_transform.origin
+		var r = prev_origin - curr_origin
 		var l = bones_in_chain_lengths[i] / r.length()
 		var l = bones_in_chain_lengths[i] / r.length()
 		# Apply the new joint position
 		# Apply the new joint position
-		bone_nodes[i].global_transform.origin = (1 - l) * bone_nodes[i+1].global_transform.origin + l * bone_nodes[i].global_transform.origin
+		bone_nodes[i].global_transform.origin = prev_origin.linear_interpolate(curr_origin, l)
 
 
 
 
+# Forward reaching pass
 func chain_forward():
 func chain_forward():
-	# Forward reaching pass
-	
 	# Set root at initial position
 	# Set root at initial position
-	bone_nodes[0].global_transform.origin = chain_origin.origin
+	bone_nodes[0].global_transform.origin = chain_origin
 	
 	
 	# Go through every bone in the bone chain
 	# Go through every bone in the bone chain
-	var i = 0
-	while i < bones_in_chain.size() - 1:
+	for i in range(bones_in_chain.size() - 1):
+		var curr_origin = bone_nodes[i].global_transform.origin
+		var next_origin = bone_nodes[i + 1].global_transform.origin
 		
 		
-		var r = (bone_nodes[i+1].global_transform.origin - bone_nodes[i].global_transform.origin)
+		var r = next_origin - curr_origin
 		var l = bones_in_chain_lengths[i] / r.length()
 		var l = bones_in_chain_lengths[i] / r.length()
-		
-		# Set the new joint position
-		var new_pos = (1 - l) * bone_nodes[i].global_transform.origin + l * bone_nodes[i+1].global_transform.origin
-		
 		# Apply the new joint position, (potentially with constraints), to the bone node
 		# Apply the new joint position, (potentially with constraints), to the bone node
-		bone_nodes[i+1].global_transform.origin = new_pos
-		
-		i += 1
+		bone_nodes[i + 1].global_transform.origin = curr_origin.linear_interpolate(next_origin, l)
 
 
 
 
+# Make all of the bones rotated correctly.
 func chain_apply_rotation():
 func chain_apply_rotation():
-	# Make all of the bones rotated correctly.
-	
 	# For each bone in the bone chain
 	# For each bone in the bone chain
 	for i in range(0, bones_in_chain.size()):
 	for i in range(0, bones_in_chain.size()):
-		
 		# Get the bone's transform, NOT converted to world space
 		# Get the bone's transform, NOT converted to world space
 		var bone_trans = get_bone_transform(i, false)
 		var bone_trans = get_bone_transform(i, false)
-		
 		# If this is the last bone in the bone chain, rotate the bone so it faces
 		# If this is the last bone in the bone chain, rotate the bone so it faces
 		# the same direction as the next to last bone in the bone chain if there are more than
 		# the same direction as the next to last bone in the bone chain if there are more than
 		# two bones. If there are only two bones, rotate the end effector towards the target
 		# two bones. If there are only two bones, rotate the end effector towards the target
-		if i == bones_in_chain.size()-1:
-			
+		if i == bones_in_chain.size() - 1:
 			if bones_in_chain.size() > 2:
 			if bones_in_chain.size() > 2:
 				# Get the bone node for this bone, and the previous bone
 				# Get the bone node for this bone, and the previous bone
 				var b_target = bone_nodes[i].global_transform
 				var b_target = bone_nodes[i].global_transform
@@ -442,11 +306,11 @@ func chain_apply_rotation():
 				var dir = (target.global_transform.origin - b_target_two.origin).normalized()
 				var dir = (target.global_transform.origin - b_target_two.origin).normalized()
 				
 				
 				# Make this bone look in the same the direction as the last bone
 				# Make this bone look in the same the direction as the last bone
-				bone_trans = bone_trans.looking_at(b_target.origin + dir, Vector3(0, 1, 0))
+				bone_trans = bone_trans.looking_at(b_target.origin + dir, Vector3.UP)
 			else:
 			else:
 				var b_target = target.global_transform
 				var b_target = target.global_transform
 				b_target.origin = skeleton.global_transform.xform_inv(b_target.origin)
 				b_target.origin = skeleton.global_transform.xform_inv(b_target.origin)
-				bone_trans = bone_trans.looking_at(b_target.origin, Vector3(0, 1, 0))
+				bone_trans = bone_trans.looking_at(b_target.origin, Vector3.UP)
 		
 		
 		# If this is NOT the last bone in the bone chain, rotate the bone to look at the next
 		# If this is NOT the last bone in the bone chain, rotate the bone to look at the next
 		# bone in the bone chain.
 		# bone in the bone chain.
@@ -463,16 +327,15 @@ func chain_apply_rotation():
 			var dir = (b_target_two.origin - b_target.origin).normalized()
 			var dir = (b_target_two.origin - b_target.origin).normalized()
 			
 			
 			# Make this bone look towards the direction of the next bone
 			# Make this bone look towards the direction of the next bone
-			bone_trans = bone_trans.looking_at(b_target.origin + dir, Vector3(0, 1, 0))
+			bone_trans = bone_trans.looking_at(b_target.origin + dir, Vector3.UP)
 		
 		
 		# The the bone's (updated) transform
 		# The the bone's (updated) transform
 		set_bone_transform(i, bone_trans)
 		set_bone_transform(i, bone_trans)
 
 
 
 
-func get_bone_transform(bone, convert_to_world_space=true):
-	
+func get_bone_transform(bone, convert_to_world_space = true):
 	# Get the global transform of the bone
 	# Get the global transform of the bone
-	var ret = skeleton.get_bone_global_pose(bone_IDs[bones_in_chain[bone]])
+	var ret: Transform = skeleton.get_bone_global_pose(bone_IDs[bones_in_chain[bone]])
 	
 	
 	# If we need to convert the bone position from bone/skeleton space to world space, we
 	# If we need to convert the bone position from bone/skeleton space to world space, we
 	# use the Xform of the skeleton (because bone/skeleton space is relative to the position of the skeleton node).
 	# use the Xform of the skeleton (because bone/skeleton space is relative to the position of the skeleton node).
@@ -486,4 +349,125 @@ func set_bone_transform(bone, trans):
 	# Set the global transform of the bone
 	# Set the global transform of the bone
 	skeleton.set_bone_global_pose(bone_IDs[bones_in_chain[bone]], trans)
 	skeleton.set_bone_global_pose(bone_IDs[bones_in_chain[bone]], trans)
 
 
+############# END OF IK SOLVER RELATED FUNCTIONS #############
+
+
+func _make_editor_sphere_at_node(node, color):
+	# So we can see the target in the editor, let's create a mesh instance,
+	# Add it as our child, and name it
+	var indicator = MeshInstance.new()
+	node.add_child(indicator)
+	indicator.name = "(EditorOnly) Visual indicator"
+
+	# We need to make a mesh for the mesh instance.
+	# The code below makes a small sphere mesh
+	var indicator_mesh = SphereMesh.new()
+	indicator_mesh.radius = 0.1
+	indicator_mesh.height = 0.2
+	indicator_mesh.radial_segments = 8
+	indicator_mesh.rings = 4
+
+	# The mesh needs a material (unless we want to use the defualt one).
+	# Let's create a material and use the EditorGizmoTexture to texture it.
+	var indicator_material = SpatialMaterial.new()
+	indicator_material.flags_unshaded = true
+	indicator_material.albedo_texture = preload("editor_gizmo_texture.png")
+	indicator_material.albedo_color = color
+	indicator_mesh.material = indicator_material
+	indicator.mesh = indicator_mesh
 
 
+
+############# SETGET FUNCTIONS #############
+
+func _set_update_mode(new_value):
+	update_mode = new_value
+	
+	set_process(false)
+	set_physics_process(false)
+	set_notify_transform(false)
+	
+	if update_mode == 0:
+		set_process(true)
+	elif update_mode == 1:
+		set_process(true)
+	elif update_mode == 2:
+		set_notify_transform(true)
+	else:
+		if debug_messages == true:
+			printerr(name, " - IK_FABRIK: Unknown update mode. NOT updating skeleton")
+		return
+
+
+func _set_skeleton_path(new_value):
+	# Because get_node doesn't work in the first call, we just want to assign instead
+	if first_call == true:
+		skeleton_path = new_value
+		return
+	
+	skeleton_path = new_value
+	
+	if skeleton_path == null:
+		if debug_messages == true:
+			printerr(name, " - IK_FABRIK: No Nodepath selected for skeleton_path!")
+		return
+	
+	var temp = get_node(skeleton_path)
+	if temp != null:
+		# If it has the method "get_bone_global_pose" it is likely a Skeleton
+		if temp.has_method("get_bone_global_pose") == true:
+			skeleton = temp
+			bone_IDs = {}
+			
+			# (Delete all of the old bone nodes and) Make all of the bone nodes for each bone in the IK chain
+			_make_bone_nodes()
+			
+			if debug_messages == true:
+				printerr(name, " - IK_FABRIK: Attached to a new skeleton")
+		# If not, then it's (likely) not a Skeleton node
+		else:
+			skeleton = null
+			if debug_messages == true:
+				printerr(name, " - IK_FABRIK: skeleton_path does not point to a skeleton!")
+	else:
+		if debug_messages == true:
+			printerr(name, " - IK_FABRIK: No Nodepath selected for skeleton_path!")
+
+
+############# OTHER (NON IK SOLVER RELATED) FUNCTIONS #############
+
+func _make_bone_nodes():
+	# Remove all of the old bone nodes
+	# TODO: (not a huge concern, as these can be removed in the editor)
+	
+	for bone in range(0, bones_in_chain.size()):
+		
+		var bone_name = bones_in_chain[bone]
+		if has_node(bone_name) == false:
+			var new_node = Spatial.new()
+			bone_nodes[bone] = new_node
+			add_child(bone_nodes[bone])
+			
+			if Engine.editor_hint == true:
+				if get_tree() != null:
+					if get_tree().edited_scene_root != null:
+						bone_nodes[bone].set_owner(get_tree().edited_scene_root)
+			
+			bone_nodes[bone].name = bone_name
+			
+		else:
+			bone_nodes[bone] = get_node(bone_name)
+		
+		# If we are in the editor, we want to make a sphere at this node
+		if Engine.editor_hint == true:
+			_make_editor_sphere_at_node(bone_nodes[bone], Color(0.65, 0, 1, 1))
+
+
+func _set_bone_chain_bones(new_value):
+	bones_in_chain = new_value
+	
+	_make_bone_nodes()
+
+
+func _set_bone_chain_lengths(new_value):
+	bones_in_chain_lengths = new_value
+	total_length = INF

+ 95 - 96
3d/ik/addons/sade/ik_look_at.gd

@@ -1,23 +1,22 @@
 tool
 tool
 extends Spatial
 extends Spatial
 
 
-export (NodePath) var skeleton_path setget _set_skeleton_path
-export (String) var bone_name = ""
-export (int, "_process", "_physics_process", "_notification", "none") var update_mode = 0 setget _set_update
-export (int, "X-up", "Y-up", "Z-up") var look_at_axis = 1
-export (bool) var use_our_rotation_x = false
-export (bool) var use_our_rotation_y = false
-export (bool) var use_our_rotation_z = false
-export (bool) var use_negative_our_rot = false
-export (Vector3) var additional_rotation = Vector3()
-export (bool) var debug_messages = false
+export(NodePath) var skeleton_path setget _set_skeleton_path
+export(String) var bone_name = ""
+export(int, "_process", "_physics_process", "_notification", "none") var update_mode = 0 setget _set_update
+export(int, "X-up", "Y-up", "Z-up") var look_at_axis = 1
+export(bool) var use_our_rotation_x = false
+export(bool) var use_our_rotation_y = false
+export(bool) var use_our_rotation_z = false
+export(bool) var use_negative_our_rot = false
+export(Vector3) var additional_rotation = Vector3()
+export(bool) var debug_messages = false
 
 
 var skeleton_to_use
 var skeleton_to_use
 var first_call = true
 var first_call = true
-const empty_vector = Vector3()
+
 
 
 func _ready():
 func _ready():
-	
 	set_process(false)
 	set_process(false)
 	set_physics_process(false)
 	set_physics_process(false)
 	set_notify_transform(false)
 	set_notify_transform(false)
@@ -36,6 +35,90 @@ func _ready():
 		_setup_for_editor()
 		_setup_for_editor()
 
 
 
 
+func _process(_delta):
+	update_skeleton()
+
+
+func _physics_process(_delta):
+	update_skeleton()
+
+
+func _notification(what):
+	if what == NOTIFICATION_TRANSFORM_CHANGED:
+		update_skeleton()
+
+
+func update_skeleton():
+	# NOTE: Because get_node doesn't work in _ready, we need to skip
+	# a call before doing anything.
+	if first_call == true:
+		first_call = false
+		if skeleton_to_use == null:
+			_set_skeleton_path(skeleton_path)
+	
+	
+	# If we do not have a skeleton and/or we're not supposed to update, then return.
+	if skeleton_to_use == null:
+		return
+	if update_mode >= 3:
+		return
+	
+	# Get the bone
+	var bone = skeleton_to_use.find_bone(bone_name)
+	
+	# If no bone is found (-1), then return (and optionally print an error)
+	if bone == -1:
+		if debug_messages == true:
+			print (name, " - IK_LookAt: No bone in skeleton found with name [", bone_name, "]!")
+		return
+	
+	# get the bone's rest position
+	var rest = skeleton_to_use.get_bone_global_pose(bone)
+	
+	# Convert our position relative to the skeleton's transform
+	var target_pos = skeleton_to_use.global_transform.xform_inv(global_transform.origin)
+	
+	# Call helper's look_at function with the chosen up axis.
+	if look_at_axis == 0:
+		rest = rest.looking_at(target_pos, Vector3(1, 0, 0))
+	elif look_at_axis == 1:
+		rest = rest.looking_at(target_pos, Vector3(0, 1, 0))
+	elif look_at_axis == 2:
+		rest = rest.looking_at(target_pos, Vector3(0, 0, 1))
+	else:
+		rest = rest.looking_at(target_pos, Vector3(0, 1, 0))
+		if debug_messages == true:
+			print (name, " - IK_LookAt: Unknown look_at_axis value!")
+	
+	# Get our rotation euler, and the bone's rotation euler
+	var rest_euler = rest.basis.get_euler()
+	var self_euler = global_transform.basis.orthonormalized().get_euler()
+	
+	# If we using negative rotation, we flip our rotation euler
+	if use_negative_our_rot == true:
+		self_euler = -self_euler
+	
+	# Apply our rotation euler, if wanted/required
+	if use_our_rotation_x == true:
+		rest_euler.x = self_euler.x
+	if use_our_rotation_y == true:
+		rest_euler.y = self_euler.y
+	if use_our_rotation_z == true:
+		rest_euler.z = self_euler.z
+	
+	# Rotate the bone by the (potentially) changed euler angle(s)
+	rest.basis = Basis(rest_euler)
+	
+	# If we have additional rotation, then rotate it by the local rotation vectors
+	if additional_rotation != Vector3.ZERO:
+		rest.basis = rest.basis.rotated(rest.basis.x, deg2rad(additional_rotation.x))
+		rest.basis = rest.basis.rotated(rest.basis.y, deg2rad(additional_rotation.y))
+		rest.basis = rest.basis.rotated(rest.basis.z, deg2rad(additional_rotation.z))
+	
+	# Finally, apply the bone rotation to the skeleton
+	skeleton_to_use.set_bone_global_pose(bone, rest)
+
+
 func _setup_for_editor():
 func _setup_for_editor():
 	# So we can see the target in the editor, let's create a mesh instance,
 	# So we can see the target in the editor, let's create a mesh instance,
 	# Add it as our child, and name it
 	# Add it as our child, and name it
@@ -88,7 +171,6 @@ func _set_update(new_value):
 
 
 
 
 func _set_skeleton_path(new_value):
 func _set_skeleton_path(new_value):
-	
 	# Because get_node doesn't work in the first call, we just want to assign instead
 	# Because get_node doesn't work in the first call, we just want to assign instead
 	# This is to get around a issue with NodePaths exposed to the editor
 	# This is to get around a issue with NodePaths exposed to the editor
 	if first_call == true:
 	if first_call == true:
@@ -119,86 +201,3 @@ func _set_skeleton_path(new_value):
 	else:
 	else:
 		if debug_messages == true:
 		if debug_messages == true:
 			print (name, " - IK_LookAt: No Nodepath selected for skeleton_path!")
 			print (name, " - IK_LookAt: No Nodepath selected for skeleton_path!")
-
-
-func update_skeleton():
-	
-	# NOTE: Because get_node doesn't work in _ready, we need to skip
-	# a call before doing anything.
-	if first_call == true:
-		first_call = false
-		if skeleton_to_use == null:
-			_set_skeleton_path(skeleton_path)
-	
-	
-	# If we do not have a skeleton and/or we're not supposed to update, then return.
-	if skeleton_to_use == null:
-		return
-	if update_mode >= 3:
-		return
-	
-	# Get the bone
-	var bone = skeleton_to_use.find_bone(bone_name)
-	
-	# If no bone is found (-1), then return (and optionally print an error)
-	if bone == -1:
-		if debug_messages == true:
-			print (name, " - IK_LookAt: No bone in skeleton found with name [", bone_name, "]!")
-		return
-	
-	# get the bone's rest position
-	var rest = skeleton_to_use.get_bone_global_pose(bone)
-	
-	# Convert our position relative to the skeleton's transform
-	var target_pos = skeleton_to_use.global_transform.xform_inv(global_transform.origin)
-	
-	# Call helper's look_at function with the chosen up axis.
-	if look_at_axis == 0:
-		rest = rest.looking_at(target_pos, Vector3(1, 0, 0))
-	elif look_at_axis == 1:
-		rest = rest.looking_at(target_pos, Vector3(0, 1, 0))
-	elif look_at_axis == 2:
-		rest = rest.looking_at(target_pos, Vector3(0, 0, 1))
-	else:
-		rest = rest.looking_at(target_pos, Vector3(0, 1, 0))
-		if debug_messages == true:
-			print (name, " - IK_LookAt: Unknown look_at_axis value!")
-	
-	# Get our rotation euler, and the bone's rotation euler
-	var rest_euler = rest.basis.get_euler()
-	var self_euler = global_transform.basis.orthonormalized().get_euler()
-	
-	# If we using negative rotation, we flip our rotation euler
-	if use_negative_our_rot == true:
-		self_euler = -self_euler
-	
-	# Apply our rotation euler, if wanted/required
-	if use_our_rotation_x == true:
-		rest_euler.x = self_euler.x
-	if use_our_rotation_y == true:
-		rest_euler.y = self_euler.y
-	if use_our_rotation_z == true:
-		rest_euler.z = self_euler.z
-	
-	# Rotate the bone by the (potentially) changed euler angle(s)
-	rest.basis = Basis(rest_euler)
-	
-	# If we have additional rotation, then rotate it by the local rotation vectors
-	if additional_rotation != empty_vector:
-		rest.basis = rest.basis.rotated(rest.basis.x, deg2rad(additional_rotation.x))
-		rest.basis = rest.basis.rotated(rest.basis.y, deg2rad(additional_rotation.y))
-		rest.basis = rest.basis.rotated(rest.basis.z, deg2rad(additional_rotation.z))
-	
-	# Finally, apply the bone rotation to the skeleton
-	skeleton_to_use.set_bone_global_pose(bone, rest)
-
-
-# Various upate methods
-# ---------------------
-func _process(delta):
-	update_skeleton()
-func _physics_process(delta):
-	update_skeleton()
-func _notification(what):
-	if what == NOTIFICATION_TRANSFORM_CHANGED:
-		update_skeleton()

+ 0 - 2
3d/ik/addons/sade/plugin_main.gd

@@ -8,7 +8,6 @@ func _enter_tree():
 	add_custom_type("IK_LookAt", "Spatial", preload("ik_look_at.gd"), preload("ik_look_at.png"))
 	add_custom_type("IK_LookAt", "Spatial", preload("ik_look_at.gd"), preload("ik_look_at.png"))
 	add_custom_type("IK_FABRIK", "Spatial", preload("ik_fabrik.gd"), preload("ik_fabrik.png"))
 	add_custom_type("IK_FABRIK", "Spatial", preload("ik_fabrik.gd"), preload("ik_fabrik.png"))
 	# ------ ---------- ------
 	# ------ ---------- ------
-	
 
 
 
 
 func _exit_tree():
 func _exit_tree():
@@ -18,4 +17,3 @@ func _exit_tree():
 	remove_custom_type("IK_LookAt")
 	remove_custom_type("IK_LookAt")
 	remove_custom_type("IK_FABRIK")
 	remove_custom_type("IK_FABRIK")
 	# ------ ---------- ------
 	# ------ ---------- ------
-	

+ 5 - 1
3d/ik/button_change_scene.gd

@@ -1,10 +1,14 @@
 extends Button
 extends Button
 
 
-export (String, FILE) var scene_to_change_to = null
+export(String, FILE) var scene_to_change_to = null
+
 
 
 func _ready():
 func _ready():
+	# warning-ignore:return_value_discarded
 	connect("pressed", self, "change_scene")
 	connect("pressed", self, "change_scene")
 
 
+
 func change_scene():
 func change_scene():
 	if scene_to_change_to != null:
 	if scene_to_change_to != null:
+		# warning-ignore:return_value_discarded
 		get_tree().change_scene(scene_to_change_to)
 		get_tree().change_scene(scene_to_change_to)

+ 0 - 8
3d/ik/default_env.tres

@@ -1,15 +1,7 @@
 [gd_resource type="Environment" load_steps=2 format=2]
 [gd_resource type="Environment" load_steps=2 format=2]
 
 
 [sub_resource type="ProceduralSky" id=1]
 [sub_resource type="ProceduralSky" id=1]
-sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
-sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
-sky_curve = 0.25
-ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
-ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
-ground_curve = 0.01
-sun_energy = 16.0
 
 
 [resource]
 [resource]
 background_mode = 2
 background_mode = 2
 background_sky = SubResource( 1 )
 background_sky = SubResource( 1 )
-

+ 29 - 14
3d/ik/fabrik_ik.tscn

@@ -67,8 +67,7 @@ material/0 = ExtResource( 3 )
 material/1 = ExtResource( 4 )
 material/1 = ExtResource( 4 )
 
 
 [node name="Camera" type="Camera" parent="."]
 [node name="Camera" type="Camera" parent="."]
-editor/display_folded = true
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 11.5014, 8.81922 )
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 11.5, 8.8 )
 fov = 74.0
 fov = 74.0
 script = ExtResource( 5 )
 script = ExtResource( 5 )
 MOVEMENT_SPEED = -6.0
 MOVEMENT_SPEED = -6.0
@@ -84,10 +83,16 @@ __meta__ = {
 }
 }
 skeleton_path = NodePath("../../../BattleBot/Armature/Skeleton")
 skeleton_path = NodePath("../../../BattleBot/Armature/Skeleton")
 bone_name = "Head"
 bone_name = "Head"
+update_mode = 0
+look_at_axis = 1
+use_our_rotation_x = false
+use_our_rotation_y = false
+use_our_rotation_z = false
+use_negative_our_rot = false
 additional_rotation = Vector3( 90, 0, 0 )
 additional_rotation = Vector3( 90, 0, 0 )
+debug_messages = false
 
 
 [node name="IK_FABRIK_Left_Arm" type="Spatial" parent="Camera/targets"]
 [node name="IK_FABRIK_Left_Arm" type="Spatial" parent="Camera/targets"]
-editor/display_folded = true
 script = ExtResource( 8 )
 script = ExtResource( 8 )
 __meta__ = {
 __meta__ = {
 "_editor_icon": ExtResource( 9 )
 "_editor_icon": ExtResource( 9 )
@@ -102,7 +107,6 @@ reset_iterations_on_update = false
 use_middle_joint_target = true
 use_middle_joint_target = true
 
 
 [node name="target" type="Spatial" parent="Camera/targets/IK_FABRIK_Left_Arm"]
 [node name="target" type="Spatial" parent="Camera/targets/IK_FABRIK_Left_Arm"]
-editor/display_folded = true
 transform = Transform( 0.518503, 0, -0.855076, 0, 1, 0, 0.855076, 0, 0.518503, 1.13159, 0, -0.155596 )
 transform = Transform( 0.518503, 0, -0.855076, 0, 1, 0, 0.855076, 0, 0.518503, 1.13159, 0, -0.155596 )
 
 
 [node name="IK_LookAt_LH" type="Spatial" parent="Camera/targets/IK_FABRIK_Left_Arm/target"]
 [node name="IK_LookAt_LH" type="Spatial" parent="Camera/targets/IK_FABRIK_Left_Arm/target"]
@@ -113,19 +117,25 @@ __meta__ = {
 }
 }
 skeleton_path = NodePath("../../../../../BattleBot/Armature/Skeleton")
 skeleton_path = NodePath("../../../../../BattleBot/Armature/Skeleton")
 bone_name = "Left_Hand"
 bone_name = "Left_Hand"
+update_mode = 0
+look_at_axis = 1
+use_our_rotation_x = false
+use_our_rotation_y = false
+use_our_rotation_z = false
+use_negative_our_rot = false
 additional_rotation = Vector3( 0, 0, 90 )
 additional_rotation = Vector3( 0, 0, 90 )
+debug_messages = false
 
 
 [node name="middle_joint_target" type="Spatial" parent="Camera/targets/IK_FABRIK_Left_Arm"]
 [node name="middle_joint_target" type="Spatial" parent="Camera/targets/IK_FABRIK_Left_Arm"]
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 7.16849, 0, -5.31922 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 7.16849, 0, -5.31922 )
 
 
 [node name="Left_UpperArm" type="Spatial" parent="Camera/targets/IK_FABRIK_Left_Arm"]
 [node name="Left_UpperArm" type="Spatial" parent="Camera/targets/IK_FABRIK_Left_Arm"]
-transform = Transform( -0.66477, 0.0771345, -0.743055, -2.23517e-008, 0.994655, 0.103252, 0.747048, 0.0686391, -0.661217, 1.53444, 0.300478, -3.63533 )
+transform = Transform( -0.66477, 0.0771345, -0.743055, -2.23517e-08, 0.994655, 0.103252, 0.747048, 0.0686391, -0.661217, 1.53444, 0.300478, -3.63533 )
 
 
 [node name="Left_LowerArm" type="Spatial" parent="Camera/targets/IK_FABRIK_Left_Arm"]
 [node name="Left_LowerArm" type="Spatial" parent="Camera/targets/IK_FABRIK_Left_Arm"]
-transform = Transform( -0.773624, -0.0228999, 0.633231, 2.98023e-008, 0.999347, 0.03614, -0.633645, 0.0279588, -0.773119, 2.94998, 0.10378, -2.37569 )
+transform = Transform( -0.773624, -0.0228999, 0.633231, 2.98023e-08, 0.999347, 0.03614, -0.633645, 0.0279588, -0.773119, 2.94998, 0.10378, -2.37569 )
 
 
 [node name="IK_FABRIK_Right_Arm" type="Spatial" parent="Camera/targets"]
 [node name="IK_FABRIK_Right_Arm" type="Spatial" parent="Camera/targets"]
-editor/display_folded = true
 script = ExtResource( 8 )
 script = ExtResource( 8 )
 __meta__ = {
 __meta__ = {
 "_editor_icon": ExtResource( 9 )
 "_editor_icon": ExtResource( 9 )
@@ -140,7 +150,6 @@ reset_iterations_on_update = false
 use_middle_joint_target = true
 use_middle_joint_target = true
 
 
 [node name="target" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm"]
 [node name="target" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm"]
-editor/display_folded = true
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.229958, 0, 0.929313 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.229958, 0, 0.929313 )
 
 
 [node name="IK_LookAt_RH" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm/target"]
 [node name="IK_LookAt_RH" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm/target"]
@@ -151,19 +160,26 @@ __meta__ = {
 }
 }
 skeleton_path = NodePath("../../../../../BattleBot/Armature/Skeleton")
 skeleton_path = NodePath("../../../../../BattleBot/Armature/Skeleton")
 bone_name = "Right_Hand"
 bone_name = "Right_Hand"
+update_mode = 0
+look_at_axis = 1
+use_our_rotation_x = false
+use_our_rotation_y = false
+use_our_rotation_z = false
+use_negative_our_rot = false
 additional_rotation = Vector3( 0, 0, 90 )
 additional_rotation = Vector3( 0, 0, 90 )
+debug_messages = false
 
 
 [node name="middle_joint_target" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm"]
 [node name="middle_joint_target" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm"]
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6.34515, 0, -3.7843 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6.34515, 0, -3.7843 )
 
 
 [node name="Right_UpperArm" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm"]
 [node name="Right_UpperArm" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm"]
-transform = Transform( -0.694982, -0.0753926, 0.715064, -7.45058e-009, 0.994488, 0.104854, -0.719028, 0.0728714, -0.691151, -1.53339, 0.300478, -3.63533 )
+transform = Transform( -0.694982, -0.0753926, 0.715064, -7.45058e-09, 0.994488, 0.104854, -0.719028, 0.0728714, -0.691151, -1.53339, 0.300478, -3.63533 )
 
 
 [node name="Right_LowerArm" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm"]
 [node name="Right_LowerArm" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm"]
-transform = Transform( -0.792023, 0.0165711, -0.610266, -1.49012e-008, 0.999631, 0.0271438, 0.610491, 0.0214986, -0.791732, -2.89561, 0.100755, -2.31866 )
+transform = Transform( -0.792023, 0.0165711, -0.610266, -1.49012e-08, 0.999631, 0.0271438, 0.610491, 0.0214986, -0.791732, -2.89561, 0.100755, -2.31866 )
 
 
 [node name="Right_Hand" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm"]
 [node name="Right_Hand" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm"]
-transform = Transform( -0.678336, 0.00698721, -0.734719, -2.32831e-009, 0.999955, 0.00950961, 0.734752, 0.00645071, -0.678305, -1.07914, 0.020072, 0.03791 )
+transform = Transform( -0.678336, 0.00698721, -0.734719, -2.32831e-09, 0.999955, 0.00950961, 0.734752, 0.00645071, -0.678305, -1.07914, 0.020072, 0.03791 )
 
 
 [node name="MeshInstance" type="MeshInstance" parent="Camera/targets"]
 [node name="MeshInstance" type="MeshInstance" parent="Camera/targets"]
 mesh = SubResource( 5 )
 mesh = SubResource( 5 )
@@ -225,9 +241,9 @@ margin_right = 1019.0
 margin_bottom = 590.0
 margin_bottom = 590.0
 text = "Next scene"
 text = "Next scene"
 script = ExtResource( 10 )
 script = ExtResource( 10 )
-scene_to_change_to = "res://fps_example.tscn"
+scene_to_change_to = "res://fps/fps_example.tscn"
 
 
-[node name="Button_Previous" type="Button" parent="Control"]
+[node name="Button_Prev" type="Button" parent="Control"]
 margin_left = 10.0
 margin_left = 10.0
 margin_top = 540.0
 margin_top = 540.0
 margin_right = 129.0
 margin_right = 129.0
@@ -236,5 +252,4 @@ text = "Previous scene"
 script = ExtResource( 10 )
 script = ExtResource( 10 )
 scene_to_change_to = "res://look_at_ik.tscn"
 scene_to_change_to = "res://look_at_ik.tscn"
 
 
-
 [editable path="BattleBot"]
 [editable path="BattleBot"]

+ 13 - 14
3d/ik/example_player.gd → 3d/ik/fps/example_player.gd

@@ -2,23 +2,25 @@ extends KinematicBody
 
 
 # Walking variables.
 # Walking variables.
 const norm_grav = -38.8
 const norm_grav = -38.8
-var vel = Vector3()
 const MAX_SPEED = 22
 const MAX_SPEED = 22
 const JUMP_SPEED = 26
 const JUMP_SPEED = 26
 const ACCEL= 8.5
 const ACCEL= 8.5
-
-# A vector for storing the direction the player intends to walk towards.
-var dir = Vector3()
-
 # Sprinting variables. Similar to the varibles above, just allowing for quicker movement
 # Sprinting variables. Similar to the varibles above, just allowing for quicker movement
 const MAX_SPRINT_SPEED = 34
 const MAX_SPRINT_SPEED = 34
 const SPRINT_ACCEL = 18
 const SPRINT_ACCEL = 18
-# A boolean to track whether or not we are sprinting
-var is_sprinting = false
-
 # How fast we slow down, and the steepest angle we can climb.
 # How fast we slow down, and the steepest angle we can climb.
 const DEACCEL= 28
 const DEACCEL= 28
 const MAX_SLOPE_ANGLE = 40
 const MAX_SLOPE_ANGLE = 40
+# How fast the bullets launch
+const LEFT_MOUSE_FIRE_TIME = 0.15
+const BULLET_SPEED = 100
+
+var vel = Vector3()
+# A vector for storing the direction the player intends to walk towards.
+var dir = Vector3()
+# A boolean to track whether or not we are sprinting
+var is_sprinting = false
+
 
 
 # We need the camera for getting directional vectors. We rotate ourselves on the Y-axis using
 # We need the camera for getting directional vectors. We rotate ourselves on the Y-axis using
 # the camera_holder to avoid rotating on more than one axis at a time.
 # the camera_holder to avoid rotating on more than one axis at a time.
@@ -38,9 +40,6 @@ var path_follow_node = null
 var right_mouse_down = false
 var right_mouse_down = false
 # A variable for tracking if we can fire using the left mouse button
 # A variable for tracking if we can fire using the left mouse button
 var left_mouse_timer = 0
 var left_mouse_timer = 0
-const LEFT_MOUSE_FIRE_TIME = 0.15
-# How fast the bullets launch
-const BULLET_SPEED = 100
 
 
 # The animation player for aiming down the sights
 # The animation player for aiming down the sights
 var anim_player = null
 var anim_player = null
@@ -52,7 +51,7 @@ var current_anim = "Starter"
 # The end of the pistol
 # The end of the pistol
 var pistol_end = null
 var pistol_end = null
 # The simple bullet rigidbody
 # The simple bullet rigidbody
-var simple_bullet = preload("res://simple_bullet.tscn")
+var simple_bullet = preload("res://fps/simple_bullet.tscn")
 
 
 
 
 func _ready():
 func _ready():
@@ -175,7 +174,7 @@ func process_input(delta):
 		var lerp_value = (lean_value - 0.5) * 2
 		var lerp_value = (lean_value - 0.5) * 2
 		path_follow_node.rotation_degrees.z = (-20 * lerp_value)
 		path_follow_node.rotation_degrees.z = (-20 * lerp_value)
 	# ----------------------------------
 	# ----------------------------------
-	
+
 
 
 func process_movement(delta):
 func process_movement(delta):
 	
 	
@@ -234,7 +233,7 @@ func _input(event):
 		pass
 		pass
 
 
 
 
-func animation_finished(anim):
+func animation_finished(_anim):
 	anim_done = true
 	anim_done = true
 
 
 
 

+ 54 - 68
3d/ik/fps_example.tscn → 3d/ik/fps/fps_example.tscn

@@ -2,14 +2,14 @@
 
 
 [ext_resource path="res://addons/sade/editor_gizmo_texture.png" type="Texture" id=1]
 [ext_resource path="res://addons/sade/editor_gizmo_texture.png" type="Texture" id=1]
 [ext_resource path="res://button_change_scene.gd" type="Script" id=2]
 [ext_resource path="res://button_change_scene.gd" type="Script" id=2]
-[ext_resource path="res://example_player.gd" type="Script" id=3]
+[ext_resource path="res://fps/example_player.gd" type="Script" id=3]
 [ext_resource path="res://addons/sade/ik_look_at.gd" type="Script" id=4]
 [ext_resource path="res://addons/sade/ik_look_at.gd" type="Script" id=4]
 [ext_resource path="res://addons/sade/ik_look_at.png" type="Texture" id=5]
 [ext_resource path="res://addons/sade/ik_look_at.png" type="Texture" id=5]
 [ext_resource path="res://addons/sade/ik_fabrik.gd" type="Script" id=6]
 [ext_resource path="res://addons/sade/ik_fabrik.gd" type="Script" id=6]
 [ext_resource path="res://addons/sade/ik_fabrik.png" type="Texture" id=7]
 [ext_resource path="res://addons/sade/ik_fabrik.png" type="Texture" id=7]
-[ext_resource path="res://weapon_pistol.dae" type="PackedScene" id=8]
-[ext_resource path="res://gun_color.tres" type="Material" id=9]
-[ext_resource path="res://gun_emission.tres" type="Material" id=10]
+[ext_resource path="res://fps/weapon_pistol.dae" type="PackedScene" id=8]
+[ext_resource path="res://fps/gun_color.tres" type="Material" id=9]
+[ext_resource path="res://fps/gun_emission.tres" type="Material" id=10]
 [ext_resource path="res://godot_battle_bot.dae" type="PackedScene" id=11]
 [ext_resource path="res://godot_battle_bot.dae" type="PackedScene" id=11]
 [ext_resource path="res://battle_bot_color.tres" type="Material" id=12]
 [ext_resource path="res://battle_bot_color.tres" type="Material" id=12]
 [ext_resource path="res://battle_bot_emission.tres" type="Material" id=13]
 [ext_resource path="res://battle_bot_emission.tres" type="Material" id=13]
@@ -64,7 +64,6 @@ tonemap_mode = 3
 ss_reflections_max_steps = 32
 ss_reflections_max_steps = 32
 ssao_enabled = true
 ssao_enabled = true
 ssao_light_affect = 1.0
 ssao_light_affect = 1.0
-ssao_quality = 1
 glow_enabled = true
 glow_enabled = true
 glow_levels/1 = true
 glow_levels/1 = true
 glow_levels/2 = true
 glow_levels/2 = true
@@ -74,8 +73,8 @@ glow_bloom = 0.06
 glow_blend_mode = 0
 glow_blend_mode = 0
 
 
 [sub_resource type="CapsuleShape" id=10]
 [sub_resource type="CapsuleShape" id=10]
-radius = 2.0
-height = 10.0
+radius = 4.0
+height = 6.0
 
 
 [sub_resource type="Curve3D" id=11]
 [sub_resource type="Curve3D" id=11]
 _data = {
 _data = {
@@ -202,24 +201,20 @@ tracks/2/keys = {
 [node name="Level" type="Spatial" parent="."]
 [node name="Level" type="Spatial" parent="."]
 
 
 [node name="Floor_plane" type="MeshInstance" parent="Level"]
 [node name="Floor_plane" type="MeshInstance" parent="Level"]
-editor/display_folded = true
 transform = Transform( 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0 )
 transform = Transform( 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0 )
 mesh = SubResource( 1 )
 mesh = SubResource( 1 )
 material/0 = SubResource( 2 )
 material/0 = SubResource( 2 )
 
 
 [node name="StaticBody" type="StaticBody" parent="Level/Floor_plane"]
 [node name="StaticBody" type="StaticBody" parent="Level/Floor_plane"]
-editor/display_folded = true
 
 
 [node name="CollisionShape" type="CollisionShape" parent="Level/Floor_plane/StaticBody"]
 [node name="CollisionShape" type="CollisionShape" parent="Level/Floor_plane/StaticBody"]
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.956119, 0 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.956119, 0 )
 shape = SubResource( 3 )
 shape = SubResource( 3 )
 
 
 [node name="Walls" type="Spatial" parent="Level"]
 [node name="Walls" type="Spatial" parent="Level"]
-editor/display_folded = true
 
 
 [node name="LargeWall" type="MeshInstance" parent="Level/Walls"]
 [node name="LargeWall" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( 1, 0, 0, 0, 10, 0, 0, 0, 10, -40.2777, 20.1853, 20.0892 )
+transform = Transform( 1, 0, 0, 0, 10, 0, 0, 0, 10, -39.9997, 20.0003, 20.0002 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 5 )
 material/0 = SubResource( 5 )
 
 
@@ -229,8 +224,7 @@ material/0 = SubResource( 5 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="LargeWall2" type="MeshInstance" parent="Level/Walls"]
 [node name="LargeWall2" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( 1, 0, 0, 0, 10, 0, 0, 0, 10, -40.2777, 20.1853, -19.9108 )
+transform = Transform( 1, 0, 0, 0, 10, 0, 0, 0, 10, -39.9997, 20.0003, -19.9998 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 5 )
 material/0 = SubResource( 5 )
 
 
@@ -240,8 +234,7 @@ material/0 = SubResource( 5 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="LargeWall3" type="MeshInstance" parent="Level/Walls"]
 [node name="LargeWall3" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( -4.37114e-008, 0, -10, 0, 10, 0, 1, 0, -4.37114e-007, -19.2777, 20.1853, -40.9108 )
+transform = Transform( -4.37114e-08, 0, -10, 0, 10, 0, 1, 0, -4.37114e-07, -18.9997, 20.0003, -40.9998 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 5 )
 material/0 = SubResource( 5 )
 
 
@@ -251,8 +244,7 @@ material/0 = SubResource( 5 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="LargeWall4" type="MeshInstance" parent="Level/Walls"]
 [node name="LargeWall4" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( -4.37114e-008, 0, -10, 0, 10, 0, 1, 0, -4.37114e-007, 20.7223, 20.1853, -40.9108 )
+transform = Transform( -4.37114e-08, 0, -10, 0, 10, 0, 1, 0, -4.37114e-07, 21.0003, 20.0003, -40.9998 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 5 )
 material/0 = SubResource( 5 )
 
 
@@ -262,8 +254,7 @@ material/0 = SubResource( 5 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="LargeWall5" type="MeshInstance" parent="Level/Walls"]
 [node name="LargeWall5" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( -1, 0, 8.74228e-007, 0, 10, 0, -8.74228e-008, 0, -10, 40.7223, 20.1853, -19.9108 )
+transform = Transform( -1, 0, 8.74228e-07, 0, 10, 0, -8.74228e-08, 0, -10, 41.0003, 20.0003, -19.9998 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 5 )
 material/0 = SubResource( 5 )
 
 
@@ -273,8 +264,7 @@ material/0 = SubResource( 5 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="LargeWall6" type="MeshInstance" parent="Level/Walls"]
 [node name="LargeWall6" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( -1, 0, 8.74228e-007, 0, 10, 0, -8.74228e-008, 0, -10, 40.7223, 20.1853, 20.0892 )
+transform = Transform( -1, 0, 8.74228e-07, 0, 10, 0, -8.74228e-08, 0, -10, 41.0003, 20.0003, 20.0002 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 5 )
 material/0 = SubResource( 5 )
 
 
@@ -284,8 +274,7 @@ material/0 = SubResource( 5 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="LargeWall7" type="MeshInstance" parent="Level/Walls"]
 [node name="LargeWall7" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( 1.31134e-007, 0, 10, 0, 10, 0, -1, 0, 1.31134e-006, 20.7223, 20.1853, 40.0892 )
+transform = Transform( 1.31134e-07, 0, 10, 0, 10, 0, -1, 0, 1.31134e-06, 21.0003, 20.0003, 40.0002 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 5 )
 material/0 = SubResource( 5 )
 
 
@@ -295,8 +284,7 @@ material/0 = SubResource( 5 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="LargeWall8" type="MeshInstance" parent="Level/Walls"]
 [node name="LargeWall8" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( 1.31134e-007, 0, 10, 0, 10, 0, -1, 0, 1.31134e-006, -19.2777, 20.1853, 40.0892 )
+transform = Transform( 1.31134e-07, 0, 10, 0, 10, 0, -1, 0, 1.31134e-06, -18.9997, 20.0003, 40.0002 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 5 )
 material/0 = SubResource( 5 )
 
 
@@ -306,8 +294,7 @@ material/0 = SubResource( 5 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="Wall" type="MeshInstance" parent="Level/Walls"]
 [node name="Wall" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( 7.54979e-008, 0, 4, 0, 4, 0, -1, 0, 3.01992e-007, -10.2777, 8.18532, 21.7815 )
+transform = Transform( 7.54979e-08, 0, 4, 0, 4, 0, -1, 0, 3.01992e-07, -9.9997, 8.00032, 22.0005 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 7 )
 material/0 = SubResource( 7 )
 
 
@@ -317,8 +304,7 @@ material/0 = SubResource( 7 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="Wall2" type="MeshInstance" parent="Level/Walls"]
 [node name="Wall2" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( 1, 0, -4.76837e-007, 0, 4, 0, 1.19209e-007, 0, 4, -20.2777, 8.18532, 15.7815 )
+transform = Transform( 1, 0, -4.76837e-07, 0, 4, 0, 1.19209e-07, 0, 4, -19.9997, 8.00032, 16.0005 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 7 )
 material/0 = SubResource( 7 )
 
 
@@ -328,8 +314,7 @@ material/0 = SubResource( 7 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="Wall3" type="MeshInstance" parent="Level/Walls"]
 [node name="Wall3" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( 1, 0, -4.76837e-007, 0, 4, 0, 1.19209e-007, 0, 4, -20.2777, 8.18532, -0.218508 )
+transform = Transform( 1, 0, -3.57627e-07, 0, 4, 0, 1.19209e-07, 0, 3, -19.9997, 8.00032, 2.00049 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 7 )
 material/0 = SubResource( 7 )
 
 
@@ -339,8 +324,7 @@ material/0 = SubResource( 7 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="Wall4" type="MeshInstance" parent="Level/Walls"]
 [node name="Wall4" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( 1, 0, -4.76837e-007, 0, 4, 0, 1.19209e-007, 0, 4, -20.2777, 8.18532, -22.2185 )
+transform = Transform( 1, 0, -4.76837e-07, 0, 4, 0, 1.19209e-07, 0, 4, -19.9997, 8.00032, -21.9995 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 7 )
 material/0 = SubResource( 7 )
 
 
@@ -350,8 +334,7 @@ material/0 = SubResource( 7 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="Wall5" type="MeshInstance" parent="Level/Walls"]
 [node name="Wall5" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( -1.62921e-007, 0, -4, 0, 4, 0, 1, 0, -6.51683e-007, -10.2777, 8.18532, -28.2185 )
+transform = Transform( -1.62921e-07, 0, -4, 0, 4, 0, 1, 0, -6.51683e-07, -9.9997, 8.00032, -27.9995 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 7 )
 material/0 = SubResource( 7 )
 
 
@@ -361,8 +344,7 @@ material/0 = SubResource( 7 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="Wall6" type="MeshInstance" parent="Level/Walls"]
 [node name="Wall6" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( -1, 0, 8.26528e-007, 0, 4, 0, -2.06632e-007, 0, -4, -0.277681, 8.18532, -22.2185 )
+transform = Transform( -1, 0, 8.26528e-07, 0, 4, 0, -2.06632e-07, 0, -4, 0.000319004, 8.00032, -21.9995 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 7 )
 material/0 = SubResource( 7 )
 
 
@@ -372,8 +354,7 @@ material/0 = SubResource( 7 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="Wall7" type="MeshInstance" parent="Level/Walls"]
 [node name="Wall7" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( -1.62921e-007, 0, -4, 0, 4, 0, 1, 0, -6.51683e-007, 9.72232, 8.18532, -16.2185 )
+transform = Transform( -1.62921e-07, 0, -4, 0, 4, 0, 1, 0, -6.51683e-07, 10.0003, 8.00032, -15.9995 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 7 )
 material/0 = SubResource( 7 )
 
 
@@ -382,20 +363,8 @@ material/0 = SubResource( 7 )
 [node name="CollisionShape" type="CollisionShape" parent="Level/Walls/Wall7/StaticBody"]
 [node name="CollisionShape" type="CollisionShape" parent="Level/Walls/Wall7/StaticBody"]
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
-[node name="Wall8" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( -1.62921e-007, 0, -4, 0, 4, 0, 1, 0, -6.51683e-007, 30.7223, 8.18532, -16.2185 )
-mesh = SubResource( 4 )
-material/0 = SubResource( 7 )
-
-[node name="StaticBody" type="StaticBody" parent="Level/Walls/Wall8"]
-
-[node name="CollisionShape" type="CollisionShape" parent="Level/Walls/Wall8/StaticBody"]
-shape = SubResource( 6 )
-
 [node name="Wall9" type="MeshInstance" parent="Level/Walls"]
 [node name="Wall9" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( 1, 0, -4.76837e-007, 0, 4, 0, 1.19209e-007, 0, 4, 24.7223, 8.18532, -26.2185 )
+transform = Transform( 1, 0, -4.76837e-07, 0, 4, 0, 1.19209e-07, 0, 4, 25.0003, 8.00032, -25.9995 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 7 )
 material/0 = SubResource( 7 )
 
 
@@ -405,8 +374,7 @@ material/0 = SubResource( 7 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="Wall10" type="MeshInstance" parent="Level/Walls"]
 [node name="Wall10" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( 0.573577, 0, 3.27661, 0, 4, 0, -0.819152, 0, 2.29431, 22.7223, 8.18532, 2.78149 )
+transform = Transform( 0.573577, 0, 3.27661, 0, 4, 0, -0.819152, 0, 2.29431, 23.0003, 8.00032, 3.00049 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 7 )
 material/0 = SubResource( 7 )
 
 
@@ -416,8 +384,7 @@ material/0 = SubResource( 7 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="Wall11" type="MeshInstance" parent="Level/Walls"]
 [node name="Wall11" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( -0.819152, 0, 2.29431, 0, 4, 0, -0.573577, 0, -3.27661, 21.9346, 8.18532, 14.4933 )
+transform = Transform( -0.819152, 0, 2.29431, 0, 4, 0, -0.573577, 0, -3.27661, 22.2126, 8.00032, 14.7123 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 7 )
 material/0 = SubResource( 7 )
 
 
@@ -427,8 +394,7 @@ material/0 = SubResource( 7 )
 shape = SubResource( 6 )
 shape = SubResource( 6 )
 
 
 [node name="Wall12" type="MeshInstance" parent="Level/Walls"]
 [node name="Wall12" type="MeshInstance" parent="Level/Walls"]
-editor/display_folded = true
-transform = Transform( -0.627507, 2.10616, 2.29431, 0.642788, 3.06418, 0, -0.439385, 1.47475, -3.27661, 14.5622, 8.18532, 9.33115 )
+transform = Transform( -0.627507, 2.10616, 2.29431, 0.642788, 3.06418, 0, -0.439385, 1.47475, -3.27661, 14.8402, 8.00032, 9.55015 )
 mesh = SubResource( 4 )
 mesh = SubResource( 4 )
 material/0 = SubResource( 7 )
 material/0 = SubResource( 7 )
 
 
@@ -467,7 +433,7 @@ Escape to free/lock mouse cursor"
 align = 1
 align = 1
 valign = 1
 valign = 1
 
 
-[node name="Button_Next" type="Button" parent="Control"]
+[node name="Button_Prev" type="Button" parent="Control"]
 margin_left = 10.0
 margin_left = 10.0
 margin_top = 540.0
 margin_top = 540.0
 margin_right = 129.0
 margin_right = 129.0
@@ -477,7 +443,6 @@ script = ExtResource( 2 )
 scene_to_change_to = "res://fabrik_ik.tscn"
 scene_to_change_to = "res://fabrik_ik.tscn"
 
 
 [node name="Crosshair" type="Control" parent="Control"]
 [node name="Crosshair" type="Control" parent="Control"]
-editor/display_folded = true
 modulate = Color( 1, 1, 1, 0.784314 )
 modulate = Color( 1, 1, 1, 0.784314 )
 margin_left = 492.0
 margin_left = 492.0
 margin_top = 280.0
 margin_top = 280.0
@@ -500,14 +465,13 @@ rect_rotation = 90.0
 script = ExtResource( 3 )
 script = ExtResource( 3 )
 
 
 [node name="CollisionShape" type="CollisionShape" parent="KinematicBody"]
 [node name="CollisionShape" type="CollisionShape" parent="KinematicBody"]
-transform = Transform( 1, 0, 0, 0, -4.37114e-008, -1, 0, 1, -4.37114e-008, 0, 7, 0 )
+transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 7, 0 )
 shape = SubResource( 10 )
 shape = SubResource( 10 )
 
 
 [node name="CameraHolder" type="Spatial" parent="KinematicBody"]
 [node name="CameraHolder" type="Spatial" parent="KinematicBody"]
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 13, 0 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 13, 0 )
 
 
 [node name="Lean_Path" type="Path" parent="KinematicBody/CameraHolder"]
 [node name="Lean_Path" type="Path" parent="KinematicBody/CameraHolder"]
-editor/display_folded = true
 curve = SubResource( 11 )
 curve = SubResource( 11 )
 
 
 [node name="PathFollow" type="PathFollow" parent="KinematicBody/CameraHolder/Lean_Path"]
 [node name="PathFollow" type="PathFollow" parent="KinematicBody/CameraHolder/Lean_Path"]
@@ -517,7 +481,6 @@ rotation_mode = 0
 loop = false
 loop = false
 
 
 [node name="IK_LookAt_Chest" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow"]
 [node name="IK_LookAt_Chest" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow"]
-editor/display_folded = true
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.451559, 0 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.451559, 0 )
 script = ExtResource( 4 )
 script = ExtResource( 4 )
 __meta__ = {
 __meta__ = {
@@ -525,18 +488,23 @@ __meta__ = {
 }
 }
 skeleton_path = NodePath("../../../../BattleBot/Armature/Skeleton")
 skeleton_path = NodePath("../../../../BattleBot/Armature/Skeleton")
 bone_name = "Chest"
 bone_name = "Chest"
+update_mode = 0
 look_at_axis = 2
 look_at_axis = 2
+use_our_rotation_x = false
+use_our_rotation_y = false
+use_our_rotation_z = false
+use_negative_our_rot = false
 additional_rotation = Vector3( -10, 0, 0 )
 additional_rotation = Vector3( -10, 0, 0 )
+debug_messages = false
 
 
 [node name="Camera" type="Camera" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest"]
 [node name="Camera" type="Camera" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest"]
-transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 0, 0 )
+transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0 )
 fov = 74.0
 fov = 74.0
 
 
 [node name="Aim_pos" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest"]
 [node name="Aim_pos" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest"]
 transform = Transform( 0.999391, 0, -0.0348995, 0, 1, 0, 0.0348995, 0, 0.999391, 0.570504, -2.2654, 2.93826 )
 transform = Transform( 0.999391, 0, -0.0348995, 0, 1, 0, 0.0348995, 0, 0.999391, 0.570504, -2.2654, 2.93826 )
 
 
 [node name="IK_FABRIK" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos"]
 [node name="IK_FABRIK" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos"]
-editor/display_folded = true
 script = ExtResource( 6 )
 script = ExtResource( 6 )
 __meta__ = {
 __meta__ = {
 "_editor_icon": ExtResource( 7 )
 "_editor_icon": ExtResource( 7 )
@@ -561,8 +529,14 @@ __meta__ = {
 }
 }
 skeleton_path = NodePath("../../../../../../../../BattleBot/Armature/Skeleton")
 skeleton_path = NodePath("../../../../../../../../BattleBot/Armature/Skeleton")
 bone_name = "Left_Hand"
 bone_name = "Left_Hand"
+update_mode = 0
+look_at_axis = 1
+use_our_rotation_x = false
+use_our_rotation_y = false
+use_our_rotation_z = false
 use_negative_our_rot = true
 use_negative_our_rot = true
 additional_rotation = Vector3( 0, 0, 90 )
 additional_rotation = Vector3( 0, 0, 90 )
+debug_messages = false
 
 
 [node name="middle_joint_target" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK"]
 [node name="middle_joint_target" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK"]
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5.85263, -2.91316, -2.77555 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5.85263, -2.91316, -2.77555 )
@@ -601,8 +575,14 @@ __meta__ = {
 }
 }
 skeleton_path = NodePath("../../../../../../../../BattleBot/Armature/Skeleton")
 skeleton_path = NodePath("../../../../../../../../BattleBot/Armature/Skeleton")
 bone_name = "Right_Hand"
 bone_name = "Right_Hand"
+update_mode = 0
+look_at_axis = 1
+use_our_rotation_x = false
+use_our_rotation_y = false
+use_our_rotation_z = false
 use_negative_our_rot = true
 use_negative_our_rot = true
 additional_rotation = Vector3( 0, 0, 90 )
 additional_rotation = Vector3( 0, 0, 90 )
+debug_messages = false
 
 
 [node name="middle_joint_target" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK_RightArm"]
 [node name="middle_joint_target" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK_RightArm"]
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.73318, -2.91316, -2.77555 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.73318, -2.91316, -2.77555 )
@@ -626,6 +606,14 @@ __meta__ = {
 }
 }
 skeleton_path = NodePath("../../../../BattleBot/Armature/Skeleton")
 skeleton_path = NodePath("../../../../BattleBot/Armature/Skeleton")
 bone_name = "Head"
 bone_name = "Head"
+update_mode = 0
+look_at_axis = 1
+use_our_rotation_x = false
+use_our_rotation_y = false
+use_our_rotation_z = false
+use_negative_our_rot = false
+additional_rotation = Vector3( 0, 0, 0 )
+debug_messages = false
 
 
 [node name="AnimationPlayer" type="AnimationPlayer" parent="KinematicBody/CameraHolder"]
 [node name="AnimationPlayer" type="AnimationPlayer" parent="KinematicBody/CameraHolder"]
 autoplay = "Start"
 autoplay = "Start"
@@ -648,13 +636,11 @@ material/1 = ExtResource( 10 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0161836, 0.315914, 1.41329 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0161836, 0.315914, 1.41329 )
 
 
 [node name="BattleBot" parent="KinematicBody" instance=ExtResource( 11 )]
 [node name="BattleBot" parent="KinematicBody" instance=ExtResource( 11 )]
-editor/display_folded = true
 
 
 [node name="godot_battle_bot" parent="KinematicBody/BattleBot/Armature/Skeleton" index="0"]
 [node name="godot_battle_bot" parent="KinematicBody/BattleBot/Armature/Skeleton" index="0"]
 material/0 = ExtResource( 12 )
 material/0 = ExtResource( 12 )
 material/1 = ExtResource( 13 )
 material/1 = ExtResource( 13 )
 
 
-
 [editable path="KinematicBody/CameraHolder/Weapon/Pistol"]
 [editable path="KinematicBody/CameraHolder/Weapon/Pistol"]
 
 
 [editable path="KinematicBody/BattleBot"]
 [editable path="KinematicBody/BattleBot"]

+ 7 - 0
3d/ik/fps/gun_color.tres

@@ -0,0 +1,7 @@
+[gd_resource type="SpatialMaterial" load_steps=2 format=2]
+
+[ext_resource path="res://fps/gun_textures.png" type="Texture" id=1]
+
+[resource]
+albedo_texture = ExtResource( 1 )
+roughness = 0.0

+ 9 - 0
3d/ik/fps/gun_emission.tres

@@ -0,0 +1,9 @@
+[gd_resource type="SpatialMaterial" format=2]
+
+[resource]
+roughness = 0.0
+emission_enabled = true
+emission = Color( 1, 0, 0, 1 )
+emission_energy = 1.0
+emission_operator = 0
+emission_on_uv2 = false

+ 0 - 0
3d/ik/gun_textures.png → 3d/ik/fps/gun_textures.png


+ 4 - 4
3d/ik/gun_textures.png.import → 3d/ik/fps/gun_textures.png.import

@@ -2,8 +2,8 @@
 
 
 importer="texture"
 importer="texture"
 type="StreamTexture"
 type="StreamTexture"
-path.s3tc="res://.import/gun_textures.png-d86dd13f7bab751a3c0100e83b6188ac.s3tc.stex"
-path.etc2="res://.import/gun_textures.png-d86dd13f7bab751a3c0100e83b6188ac.etc2.stex"
+path.s3tc="res://.import/gun_textures.png-ff36b37294b2a7b89d70248caaea5848.s3tc.stex"
+path.etc2="res://.import/gun_textures.png-ff36b37294b2a7b89d70248caaea5848.etc2.stex"
 metadata={
 metadata={
 "imported_formats": [ "s3tc", "etc2" ],
 "imported_formats": [ "s3tc", "etc2" ],
 "vram_texture": true
 "vram_texture": true
@@ -11,8 +11,8 @@ metadata={
 
 
 [deps]
 [deps]
 
 
-source_file="res://gun_textures.png"
-dest_files=[ "res://.import/gun_textures.png-d86dd13f7bab751a3c0100e83b6188ac.s3tc.stex", "res://.import/gun_textures.png-d86dd13f7bab751a3c0100e83b6188ac.etc2.stex" ]
+source_file="res://fps/gun_textures.png"
+dest_files=[ "res://.import/gun_textures.png-ff36b37294b2a7b89d70248caaea5848.s3tc.stex", "res://.import/gun_textures.png-ff36b37294b2a7b89d70248caaea5848.etc2.stex" ]
 
 
 [params]
 [params]
 
 

+ 5 - 2
3d/ik/simple_bullet.gd → 3d/ik/fps/simple_bullet.gd

@@ -1,13 +1,16 @@
 extends RigidBody
 extends RigidBody
 
 
-const KILL_TIME = 5
+const DESPAWN_TIME = 5
+
 var timer = 0
 var timer = 0
 
 
+
 func _ready():
 func _ready():
 	set_physics_process(true);
 	set_physics_process(true);
 
 
+
 func _physics_process(delta):
 func _physics_process(delta):
 	timer += delta
 	timer += delta
-	if timer > KILL_TIME:
+	if timer > DESPAWN_TIME:
 		queue_free()
 		queue_free()
 		timer = 0 # Make sure we are destroyed before we call this again!
 		timer = 0 # Make sure we are destroyed before we call this again!

+ 1 - 2
3d/ik/simple_bullet.tscn → 3d/ik/fps/simple_bullet.tscn

@@ -1,6 +1,6 @@
 [gd_scene load_steps=6 format=2]
 [gd_scene load_steps=6 format=2]
 
 
-[ext_resource path="res://simple_bullet.gd" type="Script" id=1]
+[ext_resource path="res://fps/simple_bullet.gd" type="Script" id=1]
 
 
 [sub_resource type="PhysicsMaterial" id=1]
 [sub_resource type="PhysicsMaterial" id=1]
 bounce = 0.5
 bounce = 0.5
@@ -35,4 +35,3 @@ material/0 = SubResource( 3 )
 
 
 [node name="CollisionShape" type="CollisionShape" parent="."]
 [node name="CollisionShape" type="CollisionShape" parent="."]
 shape = SubResource( 4 )
 shape = SubResource( 4 )
-

+ 0 - 0
3d/ik/weapon_pistol.dae → 3d/ik/fps/weapon_pistol.dae


+ 3 - 3
3d/ik/weapon_pistol.dae.import → 3d/ik/fps/weapon_pistol.dae.import

@@ -2,12 +2,12 @@
 
 
 importer="scene"
 importer="scene"
 type="PackedScene"
 type="PackedScene"
-path="res://.import/weapon_pistol.dae-b8ccfaa12c6b728117e9f797617f9226.scn"
+path="res://.import/weapon_pistol.dae-ed8a2a8a1d486f24880330c98eecbf74.scn"
 
 
 [deps]
 [deps]
 
 
-source_file="res://weapon_pistol.dae"
-dest_files=[ "res://.import/weapon_pistol.dae-b8ccfaa12c6b728117e9f797617f9226.scn" ]
+source_file="res://fps/weapon_pistol.dae"
+dest_files=[ "res://.import/weapon_pistol.dae-ed8a2a8a1d486f24880330c98eecbf74.scn" ]
 
 
 [params]
 [params]
 
 

+ 0 - 56
3d/ik/gun_color.tres

@@ -1,56 +0,0 @@
-[gd_resource type="SpatialMaterial" load_steps=2 format=2]
-
-[ext_resource path="res://gun_textures.png" type="Texture" id=1]
-
-[resource]
-
-render_priority = 0
-flags_transparent = false
-flags_unshaded = false
-flags_vertex_lighting = false
-flags_no_depth_test = false
-flags_use_point_size = false
-flags_world_triplanar = false
-flags_fixed_size = false
-flags_albedo_tex_force_srgb = false
-vertex_color_use_as_albedo = false
-vertex_color_is_srgb = false
-params_diffuse_mode = 0
-params_specular_mode = 0
-params_blend_mode = 0
-params_cull_mode = 0
-params_depth_draw_mode = 0
-params_line_width = 1.0
-params_point_size = 1.0
-params_billboard_mode = 0
-params_grow = false
-params_use_alpha_scissor = false
-albedo_color = Color( 1, 1, 1, 1 )
-albedo_texture = ExtResource( 1 )
-metallic = 0.0
-metallic_specular = 0.5
-metallic_texture_channel = 0
-roughness = 0.0
-roughness_texture_channel = 0
-emission_enabled = false
-normal_enabled = false
-rim_enabled = false
-clearcoat_enabled = false
-anisotropy_enabled = false
-ao_enabled = false
-depth_enabled = false
-subsurf_scatter_enabled = false
-transmission_enabled = false
-refraction_enabled = false
-detail_enabled = false
-uv1_scale = Vector3( 1, 1, 1 )
-uv1_offset = Vector3( 0, 0, 0 )
-uv1_triplanar = false
-uv1_triplanar_sharpness = 1.0
-uv2_scale = Vector3( 1, 1, 1 )
-uv2_offset = Vector3( 0, 0, 0 )
-uv2_triplanar = false
-uv2_triplanar_sharpness = 1.0
-proximity_fade_enable = false
-distance_fade_enable = false
-

+ 0 - 57
3d/ik/gun_emission.tres

@@ -1,57 +0,0 @@
-[gd_resource type="SpatialMaterial" format=2]
-
-[resource]
-
-render_priority = 0
-flags_transparent = false
-flags_unshaded = false
-flags_vertex_lighting = false
-flags_no_depth_test = false
-flags_use_point_size = false
-flags_world_triplanar = false
-flags_fixed_size = false
-flags_albedo_tex_force_srgb = false
-vertex_color_use_as_albedo = false
-vertex_color_is_srgb = false
-params_diffuse_mode = 0
-params_specular_mode = 0
-params_blend_mode = 0
-params_cull_mode = 0
-params_depth_draw_mode = 0
-params_line_width = 1.0
-params_point_size = 1.0
-params_billboard_mode = 0
-params_grow = false
-params_use_alpha_scissor = false
-albedo_color = Color( 1, 1, 1, 1 )
-metallic = 0.0
-metallic_specular = 0.5
-metallic_texture_channel = 0
-roughness = 0.0
-roughness_texture_channel = 0
-emission_enabled = true
-emission = Color( 1, 0, 0, 1 )
-emission_energy = 1.0
-emission_operator = 0
-emission_on_uv2 = false
-normal_enabled = false
-rim_enabled = false
-clearcoat_enabled = false
-anisotropy_enabled = false
-ao_enabled = false
-depth_enabled = false
-subsurf_scatter_enabled = false
-transmission_enabled = false
-refraction_enabled = false
-detail_enabled = false
-uv1_scale = Vector3( 1, 1, 1 )
-uv1_offset = Vector3( 0, 0, 0 )
-uv1_triplanar = false
-uv1_triplanar_sharpness = 1.0
-uv2_scale = Vector3( 1, 1, 1 )
-uv2_offset = Vector3( 0, 0, 0 )
-uv2_triplanar = false
-uv2_triplanar_sharpness = 1.0
-proximity_fade_enable = false
-distance_fade_enable = false
-

+ 0 - 2
3d/ik/look_at_ik.tscn

@@ -58,7 +58,6 @@ material/0 = ExtResource( 3 )
 material/1 = ExtResource( 4 )
 material/1 = ExtResource( 4 )
 
 
 [node name="Camera" type="Camera" parent="."]
 [node name="Camera" type="Camera" parent="."]
-editor/display_folded = true
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 11.5014, 8.81922 )
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 11.5014, 8.81922 )
 fov = 74.0
 fov = 74.0
 script = ExtResource( 5 )
 script = ExtResource( 5 )
@@ -123,5 +122,4 @@ text = "Next scene"
 script = ExtResource( 8 )
 script = ExtResource( 8 )
 scene_to_change_to = "res://fabrik_ik.tscn"
 scene_to_change_to = "res://fabrik_ik.tscn"
 
 
-
 [editable path="BattleBot"]
 [editable path="BattleBot"]

+ 6 - 5
3d/ik/target_from_mousepos.gd

@@ -1,15 +1,16 @@
 extends Camera
 extends Camera
 
 
-var targets = null
+export(float) var MOVEMENT_SPEED = 10
+export(bool) var flip_axis = false
 
 
-export (float) var MOVEMENT_SPEED = 10
-export (bool) var flip_axis = false
+var targets = null
 
 
 
 
 func _ready():
 func _ready():
 	targets = get_node("targets")
 	targets = get_node("targets")
 
 
-func _process(delta):
+
+func _process(_delta):
 	var mouse_to_world = project_local_ray_normal(get_viewport().get_mouse_position()) * MOVEMENT_SPEED
 	var mouse_to_world = project_local_ray_normal(get_viewport().get_mouse_position()) * MOVEMENT_SPEED
 	
 	
 	if flip_axis == false:
 	if flip_axis == false:
@@ -17,4 +18,4 @@ func _process(delta):
 	else:
 	else:
 		mouse_to_world = -mouse_to_world
 		mouse_to_world = -mouse_to_world
 	
 	
-	targets.transform.origin = mouse_to_world
+	targets.transform.origin = mouse_to_world