mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-06 07:50:22 +01:00
Many style fixes for the IK demo
This commit is contained in:
@@ -48,41 +48,41 @@ var debug_messages = false
|
||||
|
||||
func _ready():
|
||||
if target == null:
|
||||
# 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
|
||||
if has_node("target") == false:
|
||||
# NOTE: You MUST have a node called Target as a child of this node!
|
||||
# So we create one if one doesn't already exist.
|
||||
if not has_node("Target"):
|
||||
target = Spatial.new()
|
||||
add_child(target)
|
||||
|
||||
if Engine.editor_hint == true:
|
||||
if Engine.editor_hint:
|
||||
if get_tree() != null:
|
||||
if get_tree().edited_scene_root != null:
|
||||
target.set_owner(get_tree().edited_scene_root)
|
||||
|
||||
target.name = "target"
|
||||
target.name = "Target"
|
||||
else:
|
||||
target = get_node("target")
|
||||
target = $Target
|
||||
|
||||
# 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(target, Color(1, 0, 1, 1))
|
||||
if Engine.editor_hint:
|
||||
_make_editor_sphere_at_node(target, Color.magenta)
|
||||
|
||||
if middle_joint_target == null:
|
||||
if has_node("middle_joint_target") == false:
|
||||
if not has_node("MiddleJoint"):
|
||||
middle_joint_target = Spatial.new()
|
||||
add_child(middle_joint_target)
|
||||
|
||||
if Engine.editor_hint == true:
|
||||
if Engine.editor_hint:
|
||||
if get_tree() != null:
|
||||
if get_tree().edited_scene_root != null:
|
||||
middle_joint_target.set_owner(get_tree().edited_scene_root)
|
||||
|
||||
middle_joint_target.name = "middle_joint_target"
|
||||
middle_joint_target.name = "MiddleJoint"
|
||||
else:
|
||||
middle_joint_target = get_node("middle_joint_target")
|
||||
middle_joint_target = get_node("MiddleJoint")
|
||||
|
||||
# If we are in the editor, we want to make a sphere at this node
|
||||
if Engine.editor_hint == true:
|
||||
if Engine.editor_hint:
|
||||
_make_editor_sphere_at_node(middle_joint_target, Color(1, 0.24, 1, 1))
|
||||
|
||||
# Make all of the bone nodes for each bone in the IK chain
|
||||
@@ -94,20 +94,20 @@ func _ready():
|
||||
|
||||
# Various upate methods
|
||||
func _process(_delta):
|
||||
if reset_iterations_on_update == true:
|
||||
if reset_iterations_on_update:
|
||||
chain_iterations = 0
|
||||
update_skeleton()
|
||||
|
||||
|
||||
func _physics_process(_delta):
|
||||
if reset_iterations_on_update == true:
|
||||
if reset_iterations_on_update:
|
||||
chain_iterations = 0
|
||||
update_skeleton()
|
||||
|
||||
|
||||
func _notification(what):
|
||||
if what == NOTIFICATION_TRANSFORM_CHANGED:
|
||||
if reset_iterations_on_update == true:
|
||||
if reset_iterations_on_update:
|
||||
chain_iterations = 0
|
||||
update_skeleton()
|
||||
|
||||
@@ -116,7 +116,7 @@ func _notification(what):
|
||||
|
||||
func update_skeleton():
|
||||
#### ERROR CHECKING conditions
|
||||
if first_call == true:
|
||||
if first_call:
|
||||
_set_skeleton_path(skeleton_path)
|
||||
first_call = false
|
||||
|
||||
@@ -126,16 +126,16 @@ func update_skeleton():
|
||||
return
|
||||
|
||||
if bones_in_chain == null:
|
||||
if debug_messages == true:
|
||||
if debug_messages:
|
||||
printerr(name, " - IK_FABRIK: No Bones in IK chain defined!")
|
||||
return
|
||||
if bones_in_chain_lengths == null:
|
||||
if debug_messages == true:
|
||||
if debug_messages:
|
||||
printerr(name, " - IK_FABRIK: No Bone lengths in IK chain defined!")
|
||||
return
|
||||
|
||||
if bones_in_chain.size() != bones_in_chain_lengths.size():
|
||||
if debug_messages == true:
|
||||
if debug_messages:
|
||||
printerr(name, " - IK_FABRIK: bones_in_chain and bones_in_chain_lengths!")
|
||||
return
|
||||
|
||||
@@ -168,7 +168,7 @@ func update_skeleton():
|
||||
func solve_chain():
|
||||
# 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)
|
||||
if chain_iterations >= CHAIN_MAX_ITER and limit_chain_iterations == true:
|
||||
if chain_iterations >= CHAIN_MAX_ITER and limit_chain_iterations:
|
||||
return
|
||||
else:
|
||||
chain_iterations = 0
|
||||
@@ -188,7 +188,7 @@ func solve_chain():
|
||||
var target_pos = target.global_transform.origin + (dir * bones_in_chain_lengths[bone_nodes.size()-1])
|
||||
|
||||
# If we are using middle joint target (and have more than 2 bones), move our middle joint towards it!
|
||||
if use_middle_joint_target == true:
|
||||
if use_middle_joint_target:
|
||||
if bone_nodes.size() > 2:
|
||||
var middle_point_pos = middle_joint_target.global_transform.origin
|
||||
var middle_point_pos_diff = (middle_point_pos - bone_nodes[bone_nodes.size()/2].global_transform.origin)
|
||||
@@ -336,7 +336,7 @@ func get_bone_transform(bone, convert_to_world_space = true):
|
||||
|
||||
# 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).
|
||||
if convert_to_world_space == true:
|
||||
if convert_to_world_space:
|
||||
ret.origin = skeleton.global_transform.xform(ret.origin)
|
||||
|
||||
return ret
|
||||
@@ -390,43 +390,43 @@ func _set_update_mode(new_value):
|
||||
elif update_mode == 2:
|
||||
set_notify_transform(true)
|
||||
else:
|
||||
if debug_messages == true:
|
||||
if debug_messages:
|
||||
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:
|
||||
if first_call:
|
||||
skeleton_path = new_value
|
||||
return
|
||||
|
||||
skeleton_path = new_value
|
||||
|
||||
if skeleton_path == null:
|
||||
if debug_messages == true:
|
||||
if debug_messages:
|
||||
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:
|
||||
if temp.has_method("get_bone_global_pose"):
|
||||
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:
|
||||
if debug_messages:
|
||||
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:
|
||||
if debug_messages:
|
||||
printerr(name, " - IK_FABRIK: skeleton_path does not point to a skeleton!")
|
||||
else:
|
||||
if debug_messages == true:
|
||||
if debug_messages:
|
||||
printerr(name, " - IK_FABRIK: No Nodepath selected for skeleton_path!")
|
||||
|
||||
|
||||
@@ -439,12 +439,12 @@ func _make_bone_nodes():
|
||||
for bone in range(0, bones_in_chain.size()):
|
||||
|
||||
var bone_name = bones_in_chain[bone]
|
||||
if has_node(bone_name) == false:
|
||||
if not has_node(bone_name):
|
||||
var new_node = Spatial.new()
|
||||
bone_nodes[bone] = new_node
|
||||
add_child(bone_nodes[bone])
|
||||
|
||||
if Engine.editor_hint == true:
|
||||
if Engine.editor_hint:
|
||||
if get_tree() != null:
|
||||
if get_tree().edited_scene_root != null:
|
||||
bone_nodes[bone].set_owner(get_tree().edited_scene_root)
|
||||
@@ -455,7 +455,7 @@ func _make_bone_nodes():
|
||||
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:
|
||||
if Engine.editor_hint:
|
||||
_make_editor_sphere_at_node(bone_nodes[bone], Color(0.65, 0, 1, 1))
|
||||
|
||||
|
||||
|
||||
@@ -32,10 +32,10 @@ func _ready():
|
||||
elif update_mode == 2:
|
||||
set_notify_transform(true)
|
||||
else:
|
||||
if debug_messages == true:
|
||||
print (name, " - IK_LookAt: Unknown update mode. NOT updating skeleton")
|
||||
if debug_messages:
|
||||
print(name, " - IK_LookAt: Unknown update mode. NOT updating skeleton")
|
||||
|
||||
if Engine.editor_hint == true:
|
||||
if Engine.editor_hint:
|
||||
_setup_for_editor()
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ func _notification(what):
|
||||
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:
|
||||
if first_call:
|
||||
first_call = false
|
||||
if skeleton_to_use == null:
|
||||
_set_skeleton_path(skeleton_path)
|
||||
@@ -70,10 +70,10 @@ func update_skeleton():
|
||||
# Get the bone index.
|
||||
var bone: int = skeleton_to_use.find_bone(bone_name)
|
||||
|
||||
# If no bone is found (-1), then return and optionally print an error.
|
||||
# If no bone is found (-1), then return and optionally printan error.
|
||||
if bone == -1:
|
||||
if debug_messages == true:
|
||||
print (name, " - IK_LookAt: No bone in skeleton found with name [", bone_name, "]!")
|
||||
if debug_messages:
|
||||
print(name, " - IK_LookAt: No bone in skeleton found with name [", bone_name, "]!")
|
||||
return
|
||||
|
||||
# get the bone's global transform pose.
|
||||
@@ -91,23 +91,23 @@ func update_skeleton():
|
||||
rest = rest.looking_at(target_pos, Vector3.FORWARD)
|
||||
else:
|
||||
rest = rest.looking_at(target_pos, Vector3.UP)
|
||||
if debug_messages == true:
|
||||
print (name, " - IK_LookAt: Unknown look_at_axis value!")
|
||||
if debug_messages:
|
||||
print(name, " - IK_LookAt: Unknown look_at_axis value!")
|
||||
|
||||
# Get the rotation euler of the bone and of this node.
|
||||
var rest_euler = rest.basis.get_euler()
|
||||
var self_euler = global_transform.basis.orthonormalized().get_euler()
|
||||
|
||||
# Flip the rotation euler if using negative rotation.
|
||||
if use_negative_our_rot == true:
|
||||
if use_negative_our_rot:
|
||||
self_euler = -self_euler
|
||||
|
||||
# Apply this node's rotation euler on each axis, if wanted/required.
|
||||
if use_our_rotation_x == true:
|
||||
if use_our_rotation_x:
|
||||
rest_euler.x = self_euler.x
|
||||
if use_our_rotation_y == true:
|
||||
if use_our_rotation_y:
|
||||
rest_euler.y = self_euler.y
|
||||
if use_our_rotation_z == true:
|
||||
if use_our_rotation_z:
|
||||
rest_euler.z = self_euler.z
|
||||
|
||||
# Make a new basis with the, potentially, changed euler angles.
|
||||
@@ -167,25 +167,25 @@ func _set_update(new_value):
|
||||
# Based on the value of passed to update, enable the correct process.
|
||||
if update_mode == 0:
|
||||
set_process(true)
|
||||
if debug_messages == true:
|
||||
print (name, " - IK_LookAt: updating skeleton using _process...")
|
||||
if debug_messages:
|
||||
print(name, " - IK_LookAt: updating skeleton using _process...")
|
||||
elif update_mode == 1:
|
||||
set_physics_process(true)
|
||||
if debug_messages == true:
|
||||
print (name, " - IK_LookAt: updating skeleton using _physics_process...")
|
||||
if debug_messages:
|
||||
print(name, " - IK_LookAt: updating skeleton using _physics_process...")
|
||||
elif update_mode == 2:
|
||||
set_notify_transform(true)
|
||||
if debug_messages == true:
|
||||
print (name, " - IK_LookAt: updating skeleton using _notification...")
|
||||
if debug_messages:
|
||||
print(name, " - IK_LookAt: updating skeleton using _notification...")
|
||||
else:
|
||||
if debug_messages == true:
|
||||
print (name, " - IK_LookAt: NOT updating skeleton due to unknown update method...")
|
||||
if debug_messages:
|
||||
print(name, " - IK_LookAt: NOT updating skeleton due to unknown update method...")
|
||||
|
||||
|
||||
func _set_skeleton_path(new_value):
|
||||
# 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.
|
||||
if first_call == true:
|
||||
if first_call:
|
||||
skeleton_path = new_value
|
||||
return
|
||||
|
||||
@@ -193,8 +193,8 @@ func _set_skeleton_path(new_value):
|
||||
skeleton_path = new_value
|
||||
|
||||
if skeleton_path == null:
|
||||
if debug_messages == true:
|
||||
print (name, " - IK_LookAt: No Nodepath selected for skeleton_path!")
|
||||
if debug_messages:
|
||||
print(name, " - IK_LookAt: No Nodepath selected for skeleton_path!")
|
||||
return
|
||||
|
||||
# Get the node at that location, if there is one.
|
||||
@@ -202,12 +202,12 @@ func _set_skeleton_path(new_value):
|
||||
if temp != null:
|
||||
if temp is Skeleton:
|
||||
skeleton_to_use = temp
|
||||
if debug_messages == true:
|
||||
print (name, " - IK_LookAt: attached to (new) skeleton")
|
||||
if debug_messages:
|
||||
print(name, " - IK_LookAt: attached to (new) skeleton")
|
||||
else:
|
||||
skeleton_to_use = null
|
||||
if debug_messages == true:
|
||||
print (name, " - IK_LookAt: skeleton_path does not point to a skeleton!")
|
||||
if debug_messages:
|
||||
print(name, " - IK_LookAt: skeleton_path does not point to a skeleton!")
|
||||
else:
|
||||
if debug_messages == true:
|
||||
print (name, " - IK_LookAt: No Nodepath selected for skeleton_path!")
|
||||
if debug_messages:
|
||||
print(name, " - IK_LookAt: No Nodepath selected for skeleton_path!")
|
||||
|
||||
@@ -3,17 +3,11 @@ extends EditorPlugin
|
||||
|
||||
func _enter_tree():
|
||||
# Plugin Initialization here!
|
||||
|
||||
# ------ IK STUFF ------
|
||||
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"))
|
||||
# ------ ---------- ------
|
||||
|
||||
|
||||
func _exit_tree():
|
||||
# Plugin Clean-up here!
|
||||
|
||||
# ------ IK STUFF ------
|
||||
remove_custom_type("IK_LookAt")
|
||||
remove_custom_type("IK_FABRIK")
|
||||
# ------ ---------- ------
|
||||
|
||||
@@ -52,7 +52,7 @@ roughness = 0.0
|
||||
|
||||
[node name="FABRIK_IK" type="Spatial"]
|
||||
|
||||
[node name="Floor_plane" type="MeshInstance" parent="."]
|
||||
[node name="Floor" type="MeshInstance" parent="."]
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = SubResource( 2 )
|
||||
|
||||
@@ -75,29 +75,19 @@ script = ExtResource( 5 )
|
||||
MOVEMENT_SPEED = -8.0
|
||||
flip_axis = true
|
||||
|
||||
[node name="targets" type="Spatial" parent="Camera"]
|
||||
[node name="Targets" type="Spatial" parent="Camera"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -8 )
|
||||
|
||||
[node name="IK_LookAt_Head" type="Spatial" parent="Camera/targets"]
|
||||
[node name="IK_LookAt_Head" type="Spatial" parent="Camera/Targets"]
|
||||
script = ExtResource( 6 )
|
||||
__meta__ = {
|
||||
"_editor_icon": ExtResource( 7 )
|
||||
}
|
||||
skeleton_path = NodePath("../../../BattleBot/Armature/Skeleton")
|
||||
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 )
|
||||
position_using_additional_bone = false
|
||||
additional_bone_name = ""
|
||||
additional_bone_length = 1.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"]
|
||||
script = ExtResource( 8 )
|
||||
__meta__ = {
|
||||
"_editor_icon": ExtResource( 9 )
|
||||
@@ -105,16 +95,14 @@ __meta__ = {
|
||||
skeleton_path = NodePath("../../../BattleBot/Armature/Skeleton")
|
||||
bones_in_chain = PoolStringArray( "Left_UpperArm", "Left_LowerArm" )
|
||||
bones_in_chain_lengths = PoolRealArray( 1.97, 3 )
|
||||
update_mode = 0
|
||||
chain_iterations = 10
|
||||
limit_chain_iterations = false
|
||||
reset_iterations_on_update = false
|
||||
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"]
|
||||
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"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.343393, -0.133381, 0.836605 )
|
||||
script = ExtResource( 6 )
|
||||
__meta__ = {
|
||||
@@ -122,28 +110,21 @@ __meta__ = {
|
||||
}
|
||||
skeleton_path = NodePath("../../../../../BattleBot/Armature/Skeleton")
|
||||
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 )
|
||||
position_using_additional_bone = true
|
||||
additional_bone_name = "Left_LowerArm"
|
||||
additional_bone_length = 3.0
|
||||
debug_messages = false
|
||||
|
||||
[node name="middle_joint_target" type="Spatial" parent="Camera/targets/IK_FABRIK_Left_Arm"]
|
||||
[node name="MiddleJoint" 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 )
|
||||
|
||||
[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-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-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"]
|
||||
script = ExtResource( 8 )
|
||||
__meta__ = {
|
||||
"_editor_icon": ExtResource( 9 )
|
||||
@@ -151,16 +132,13 @@ __meta__ = {
|
||||
skeleton_path = NodePath("../../../BattleBot/Armature/Skeleton")
|
||||
bones_in_chain = PoolStringArray( "Right_UpperArm", "Right_LowerArm", "Right_Hand" )
|
||||
bones_in_chain_lengths = PoolRealArray( 1.97, 3, 1.2 )
|
||||
update_mode = 0
|
||||
chain_iterations = 0
|
||||
limit_chain_iterations = false
|
||||
reset_iterations_on_update = false
|
||||
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"]
|
||||
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"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0544824, -0.133381, 0.332403 )
|
||||
script = ExtResource( 6 )
|
||||
__meta__ = {
|
||||
@@ -168,31 +146,21 @@ __meta__ = {
|
||||
}
|
||||
skeleton_path = NodePath("../../../../../BattleBot/Armature/Skeleton")
|
||||
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 )
|
||||
position_using_additional_bone = false
|
||||
additional_bone_name = ""
|
||||
additional_bone_length = 1.0
|
||||
debug_messages = false
|
||||
|
||||
[node name="middle_joint_target" type="Spatial" parent="Camera/targets/IK_FABRIK_Right_Arm"]
|
||||
[node name="MiddleJoint" 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 )
|
||||
|
||||
[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-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-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-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="1MeterCube" type="MeshInstance" parent="Camera/Targets"]
|
||||
mesh = SubResource( 5 )
|
||||
material/0 = SubResource( 6 )
|
||||
|
||||
@@ -225,7 +193,7 @@ Move mouse to move IK targets
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="Label_extra" type="Label" parent="Control/Panel"]
|
||||
[node name="LabelExtra" type="Label" parent="Control/Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 12.0
|
||||
@@ -241,7 +209,7 @@ __meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label_left" type="Label" parent="Control/Panel"]
|
||||
[node name="LabelLeft" type="Label" parent="Control/Panel"]
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
margin_left = -248.0
|
||||
@@ -251,7 +219,7 @@ margin_bottom = 18.0
|
||||
text = "Left Hand"
|
||||
align = 1
|
||||
|
||||
[node name="Label_right" type="Label" parent="Control/Panel"]
|
||||
[node name="LabelRight" type="Label" parent="Control/Panel"]
|
||||
margin_left = 136.0
|
||||
margin_top = 5.0
|
||||
margin_right = 249.0
|
||||
@@ -259,7 +227,7 @@ margin_bottom = 19.0
|
||||
text = "Right Hand"
|
||||
align = 1
|
||||
|
||||
[node name="Button_Next" type="Button" parent="Control"]
|
||||
[node name="ButtonNext" type="Button" parent="Control"]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
@@ -272,7 +240,7 @@ text = "Next scene"
|
||||
script = ExtResource( 10 )
|
||||
scene_to_change_to = "res://skeleton_ik.tscn"
|
||||
|
||||
[node name="Button_Prev" type="Button" parent="Control"]
|
||||
[node name="ButtonPrev" type="Button" parent="Control"]
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
@@ -281,6 +249,9 @@ margin_right = 129.0
|
||||
margin_bottom = -10.0
|
||||
text = "Previous scene"
|
||||
script = ExtResource( 10 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
scene_to_change_to = "res://look_at_ik.tscn"
|
||||
|
||||
[editable path="BattleBot"]
|
||||
|
||||
@@ -22,10 +22,6 @@ var dir = Vector3()
|
||||
var is_sprinting = false
|
||||
|
||||
|
||||
# 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.
|
||||
var camera
|
||||
var camera_holder
|
||||
# You may need to adjust depending on the sensitivity of your mouse
|
||||
var MOUSE_SENSITIVITY = 0.08
|
||||
|
||||
@@ -34,37 +30,35 @@ var jump_button_down = false
|
||||
|
||||
# The current lean value (our position on the lean track) and the path follow node
|
||||
var lean_value = 0.5
|
||||
var path_follow_node = null
|
||||
|
||||
# A variable for tracking if the right mouse button is down.
|
||||
var right_mouse_down = false
|
||||
# A variable for tracking if we can fire using the left mouse button
|
||||
var left_mouse_timer = 0
|
||||
|
||||
# The animation player for aiming down the sights
|
||||
var anim_player = null
|
||||
# A boolean for tracking whether we can change animations or not
|
||||
var anim_done = true
|
||||
# The current animation name
|
||||
var current_anim = "Starter"
|
||||
|
||||
# The end of the pistol
|
||||
var pistol_end = null
|
||||
# The simple bullet rigidbody
|
||||
var simple_bullet = preload("res://fps/simple_bullet.tscn")
|
||||
|
||||
|
||||
# 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.
|
||||
onready var camera_holder = $CameraHolder
|
||||
onready var camera = $CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/Camera
|
||||
onready var path_follow_node = $CameraHolder/LeanPath/PathFollow
|
||||
# The animation player for aiming down the sights.
|
||||
onready var anim_player = $CameraHolder/AnimationPlayer
|
||||
# The end of the pistol.
|
||||
onready var pistol_end = $CameraHolder/Weapon/Pistol/PistolEnd
|
||||
|
||||
|
||||
func _ready():
|
||||
|
||||
camera = get_node("CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Camera")
|
||||
camera_holder = get_node("CameraHolder")
|
||||
path_follow_node = get_node("CameraHolder/Lean_Path/PathFollow")
|
||||
|
||||
anim_player = get_node("CameraHolder/AnimationPlayer")
|
||||
anim_player.connect("animation_finished", self, "animation_finished")
|
||||
|
||||
pistol_end = get_node("CameraHolder/Weapon/Pistol/Pistol_end")
|
||||
|
||||
set_physics_process(true)
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
set_process_input(true)
|
||||
@@ -100,10 +94,10 @@ func process_input(delta):
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
|
||||
if Input.is_mouse_button_pressed(2):
|
||||
if right_mouse_down == false:
|
||||
if not right_mouse_down:
|
||||
right_mouse_down = true
|
||||
|
||||
if anim_done == true:
|
||||
if anim_done:
|
||||
if current_anim != "Aiming":
|
||||
anim_player.play("Aiming")
|
||||
current_anim = "Aiming"
|
||||
@@ -140,7 +134,7 @@ func process_input(delta):
|
||||
# ----------------------------------
|
||||
# Jumping
|
||||
if Input.is_key_pressed(KEY_SPACE):
|
||||
if jump_button_down == false:
|
||||
if not jump_button_down:
|
||||
jump_button_down = true
|
||||
if is_on_floor():
|
||||
vel.y = JUMP_SPEED
|
||||
@@ -197,7 +191,7 @@ func process_movement(delta):
|
||||
|
||||
var accel
|
||||
if dir.dot(hvel) > 0:
|
||||
if is_sprinting == false:
|
||||
if not is_sprinting:
|
||||
accel = ACCEL
|
||||
else:
|
||||
accel = SPRINT_ACCEL
|
||||
|
||||
@@ -77,7 +77,7 @@ _data = {
|
||||
|
||||
[sub_resource type="Animation" id=12]
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos:translation")
|
||||
tracks/0/path = NodePath("LeanPath/PathFollow/IK_LookAt_Chest/AimPos:translation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
@@ -89,7 +89,7 @@ tracks/0/keys = {
|
||||
"values": [ Vector3( 0.570504, -2.2654, 2.93826 ), Vector3( 0, -1.36445, 3.78817 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos:rotation_degrees")
|
||||
tracks/1/path = NodePath("LeanPath/PathFollow/IK_LookAt_Chest/AimPos:rotation_degrees")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
@@ -101,7 +101,7 @@ tracks/1/keys = {
|
||||
"values": [ Vector3( 0, -2, 0 ), Vector3( 0, 0, 0 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("Lean_Path/PathFollow/IK_LookAt_Chest/Camera:fov")
|
||||
tracks/2/path = NodePath("LeanPath/PathFollow/IK_LookAt_Chest/Camera:fov")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
@@ -115,7 +115,7 @@ tracks/2/keys = {
|
||||
|
||||
[sub_resource type="Animation" id=13]
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Lean_Path/PathFollow/IK_LookAt_Chest/Camera:fov")
|
||||
tracks/0/path = NodePath("LeanPath/PathFollow/IK_LookAt_Chest/Camera:fov")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
@@ -127,7 +127,7 @@ tracks/0/keys = {
|
||||
"values": [ 60.0, 80.0 ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos:translation")
|
||||
tracks/1/path = NodePath("LeanPath/PathFollow/IK_LookAt_Chest/AimPos:translation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
@@ -139,7 +139,7 @@ tracks/1/keys = {
|
||||
"values": [ Vector3( 0, -1.36445, 3.78817 ), Vector3( 0.570504, -2.2654, 2.93826 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos:rotation_degrees")
|
||||
tracks/2/path = NodePath("LeanPath/PathFollow/IK_LookAt_Chest/AimPos:rotation_degrees")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
@@ -153,7 +153,7 @@ tracks/2/keys = {
|
||||
|
||||
[sub_resource type="Animation" id=14]
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos:translation")
|
||||
tracks/0/path = NodePath("LeanPath/PathFollow/IK_LookAt_Chest/AimPos:translation")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
@@ -165,7 +165,7 @@ tracks/0/keys = {
|
||||
"values": [ Vector3( 0.570504, -2.2654, 2.93826 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos:rotation_degrees")
|
||||
tracks/1/path = NodePath("LeanPath/PathFollow/IK_LookAt_Chest/AimPos:rotation_degrees")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
@@ -177,7 +177,7 @@ tracks/1/keys = {
|
||||
"values": [ Vector3( 0, -2, 0 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("Lean_Path/PathFollow/IK_LookAt_Chest/Camera:fov")
|
||||
tracks/2/path = NodePath("LeanPath/PathFollow/IK_LookAt_Chest/Camera:fov")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
@@ -189,18 +189,18 @@ tracks/2/keys = {
|
||||
"values": [ 80.0 ]
|
||||
}
|
||||
|
||||
[node name="LookAt_IK" type="Spatial"]
|
||||
[node name="FPSExample" type="Spatial"]
|
||||
|
||||
[node name="Level" type="Spatial" parent="."]
|
||||
|
||||
[node name="Floor_plane" type="MeshInstance" parent="Level"]
|
||||
[node name="Floor" type="MeshInstance" parent="Level"]
|
||||
transform = Transform( 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0 )
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = SubResource( 2 )
|
||||
|
||||
[node name="StaticBody" type="StaticBody" parent="Level/Floor_plane"]
|
||||
[node name="StaticBody" type="StaticBody" parent="Level/Floor"]
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="Level/Floor_plane/StaticBody"]
|
||||
[node name="CollisionShape" type="CollisionShape" parent="Level/Floor/StaticBody"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.956119, 0 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
@@ -430,7 +430,7 @@ Escape to free/lock mouse cursor"
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="Button_Prev" type="Button" parent="Control"]
|
||||
[node name="ButtonPrev" type="Button" parent="Control"]
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
@@ -439,7 +439,10 @@ margin_right = 129.0
|
||||
margin_bottom = -10.0
|
||||
text = "Previous scene"
|
||||
script = ExtResource( 2 )
|
||||
scene_to_change_to = "res://fabrik_ik.tscn"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
scene_to_change_to = "res://skeleton_ik.tscn"
|
||||
|
||||
[node name="Crosshair" type="Control" parent="Control"]
|
||||
modulate = Color( 1, 1, 1, 0.784314 )
|
||||
@@ -480,16 +483,16 @@ shape = SubResource( 10 )
|
||||
[node name="CameraHolder" type="Spatial" parent="KinematicBody"]
|
||||
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="LeanPath" type="Path" parent="KinematicBody/CameraHolder"]
|
||||
curve = SubResource( 11 )
|
||||
|
||||
[node name="PathFollow" type="PathFollow" parent="KinematicBody/CameraHolder/Lean_Path"]
|
||||
[node name="PathFollow" type="PathFollow" parent="KinematicBody/CameraHolder/LeanPath"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0412404, 0.205172, 0 )
|
||||
offset = 2.71865
|
||||
rotation_mode = 0
|
||||
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/LeanPath/PathFollow"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.451559, 0 )
|
||||
script = ExtResource( 4 )
|
||||
__meta__ = {
|
||||
@@ -497,26 +500,17 @@ __meta__ = {
|
||||
}
|
||||
skeleton_path = NodePath("../../../../BattleBot/Armature/Skeleton")
|
||||
bone_name = "Chest"
|
||||
update_mode = 0
|
||||
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 )
|
||||
position_using_additional_bone = false
|
||||
additional_bone_name = ""
|
||||
additional_bone_length = 1.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/LeanPath/PathFollow/IK_LookAt_Chest"]
|
||||
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0 )
|
||||
fov = 74.0
|
||||
|
||||
[node name="Aim_pos" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest"]
|
||||
[node name="AimPos" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/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 )
|
||||
|
||||
[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/LeanPath/PathFollow/IK_LookAt_Chest/AimPos"]
|
||||
script = ExtResource( 6 )
|
||||
__meta__ = {
|
||||
"_editor_icon": ExtResource( 7 )
|
||||
@@ -524,16 +518,13 @@ __meta__ = {
|
||||
skeleton_path = NodePath("../../../../../../BattleBot/Armature/Skeleton")
|
||||
bones_in_chain = PoolStringArray( "Left_UpperArm", "Left_LowerArm", "Left_Hand" )
|
||||
bones_in_chain_lengths = PoolRealArray( 1.97, 3, 0.1 )
|
||||
update_mode = 0
|
||||
chain_iterations = 0
|
||||
limit_chain_iterations = false
|
||||
reset_iterations_on_update = false
|
||||
use_middle_joint_target = true
|
||||
|
||||
[node name="target" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK"]
|
||||
[node name="Target" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.54883, -0.0335302, -0.934144 )
|
||||
|
||||
[node name="IK_LookAt" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK/target"]
|
||||
[node name="IK_LookAt" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK/Target"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.300601, 0, 0.714191 )
|
||||
script = ExtResource( 4 )
|
||||
__meta__ = {
|
||||
@@ -541,31 +532,22 @@ __meta__ = {
|
||||
}
|
||||
skeleton_path = NodePath("../../../../../../../../BattleBot/Armature/Skeleton")
|
||||
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
|
||||
additional_rotation = Vector3( 0, 0, 90 )
|
||||
position_using_additional_bone = false
|
||||
additional_bone_name = ""
|
||||
additional_bone_length = 1.0
|
||||
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="MiddleJoint" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5.85263, -2.91316, -2.77555 )
|
||||
|
||||
[node name="Left_UpperArm" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK"]
|
||||
[node name="Left_UpperArm" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK"]
|
||||
transform = Transform( -0.985848, -0.0154234, 0.16693, -0.0140715, 0.999858, 0.00927825, -0.167049, 0.00679813, -0.985925, 1.5529, -1.84646, -6.07288 )
|
||||
|
||||
[node name="Left_LowerArm" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK"]
|
||||
[node name="Left_LowerArm" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK"]
|
||||
transform = Transform( -0.980952, 0.0992109, 0.167001, 0.116307, 0.988573, 0.0958931, -0.155579, 0.11349, -0.981282, 1.2349, -1.86413, -4.19466 )
|
||||
|
||||
[node name="Left_Hand" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK"]
|
||||
[node name="Left_Hand" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK"]
|
||||
transform = Transform( -0.962426, 0.0909643, 0.255854, 0.128209, 0.982809, 0.132853, -0.23937, 0.160664, -0.957543, 0.737802, -2.14957, -1.27378 )
|
||||
|
||||
[node name="IK_FABRIK_RightArm" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos"]
|
||||
[node name="IK_FABRIK_RightArm" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos"]
|
||||
script = ExtResource( 6 )
|
||||
__meta__ = {
|
||||
"_editor_icon": ExtResource( 7 )
|
||||
@@ -573,16 +555,13 @@ __meta__ = {
|
||||
skeleton_path = NodePath("../../../../../../BattleBot/Armature/Skeleton")
|
||||
bones_in_chain = PoolStringArray( "Right_UpperArm", "Right_LowerArm", "Right_Hand" )
|
||||
bones_in_chain_lengths = PoolRealArray( 1.97, 3, 0.1 )
|
||||
update_mode = 0
|
||||
chain_iterations = 0
|
||||
limit_chain_iterations = false
|
||||
reset_iterations_on_update = false
|
||||
use_middle_joint_target = true
|
||||
|
||||
[node name="target" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK_RightArm"]
|
||||
[node name="Target" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK_RightArm"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.285662, -0.0335302, -1.05271 )
|
||||
|
||||
[node name="IK_LookAt" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK_RightArm/target"]
|
||||
[node name="IK_LookAt" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK_RightArm/Target"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00396007, 0, 0.834561 )
|
||||
script = ExtResource( 4 )
|
||||
__meta__ = {
|
||||
@@ -590,33 +569,24 @@ __meta__ = {
|
||||
}
|
||||
skeleton_path = NodePath("../../../../../../../../BattleBot/Armature/Skeleton")
|
||||
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
|
||||
additional_rotation = Vector3( 0, 0, 90 )
|
||||
position_using_additional_bone = false
|
||||
additional_bone_name = ""
|
||||
additional_bone_length = 1.0
|
||||
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="MiddleJoint" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK_RightArm"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.73318, -2.91316, -2.77555 )
|
||||
|
||||
[node name="Right_UpperArm" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK_RightArm"]
|
||||
[node name="Right_UpperArm" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK_RightArm"]
|
||||
|
||||
[node name="Right_LowerArm" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK_RightArm"]
|
||||
[node name="Right_LowerArm" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK_RightArm"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5.85263, -2.91316, -2.77555 )
|
||||
|
||||
[node name="Right_Hand" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos/IK_FABRIK_RightArm"]
|
||||
[node name="Right_Hand" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos/IK_FABRIK_RightArm"]
|
||||
|
||||
[node name="RemoteTransform" type="RemoteTransform" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow/IK_LookAt_Chest/Aim_pos"]
|
||||
[node name="RemoteTransform" type="RemoteTransform" parent="KinematicBody/CameraHolder/LeanPath/PathFollow/IK_LookAt_Chest/AimPos"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.505047, 0.268441 )
|
||||
remote_path = NodePath("../../../../../Weapon/Pistol")
|
||||
|
||||
[node name="IK_LookAt_Head" type="Spatial" parent="KinematicBody/CameraHolder/Lean_Path/PathFollow"]
|
||||
[node name="IK_LookAt_Head" type="Spatial" parent="KinematicBody/CameraHolder/LeanPath/PathFollow"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.14041, -2.57003 )
|
||||
script = ExtResource( 4 )
|
||||
__meta__ = {
|
||||
@@ -624,17 +594,6 @@ __meta__ = {
|
||||
}
|
||||
skeleton_path = NodePath("../../../../BattleBot/Armature/Skeleton")
|
||||
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 )
|
||||
position_using_additional_bone = false
|
||||
additional_bone_name = ""
|
||||
additional_bone_length = 1.0
|
||||
debug_messages = false
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="KinematicBody/CameraHolder"]
|
||||
autoplay = "Start"
|
||||
@@ -653,7 +612,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
|
||||
material/0 = ExtResource( 9 )
|
||||
material/1 = ExtResource( 10 )
|
||||
|
||||
[node name="Pistol_end" type="Spatial" parent="KinematicBody/CameraHolder/Weapon/Pistol"]
|
||||
[node name="PistolEnd" type="Spatial" parent="KinematicBody/CameraHolder/Weapon/Pistol"]
|
||||
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 )]
|
||||
|
||||
@@ -13,4 +13,4 @@ func _physics_process(delta):
|
||||
timer += delta
|
||||
if timer > DESPAWN_TIME:
|
||||
queue_free()
|
||||
timer = 0 # Make sure we are destroyed before we call this again!
|
||||
timer = 0
|
||||
|
||||
@@ -12,7 +12,7 @@ dest_files=[ "res://.import/weapon_pistol.dae-ed8a2a8a1d486f24880330c98eecbf74.s
|
||||
[params]
|
||||
|
||||
nodes/root_type="Spatial"
|
||||
nodes/root_name="Scene Root"
|
||||
nodes/root_name="WeaponPistol"
|
||||
nodes/root_scale=1.0
|
||||
nodes/custom_script=""
|
||||
nodes/storage=0
|
||||
|
||||
@@ -12,7 +12,7 @@ dest_files=[ "res://.import/godot_battle_bot.dae-eca9fb346b160636fd03ddf258af136
|
||||
[params]
|
||||
|
||||
nodes/root_type="Spatial"
|
||||
nodes/root_name="Scene Root"
|
||||
nodes/root_name="GodotBattleBot"
|
||||
nodes/root_scale=1.0
|
||||
nodes/custom_script=""
|
||||
nodes/storage=0
|
||||
|
||||
@@ -41,9 +41,9 @@ glow_intensity = 0.2
|
||||
glow_bloom = 0.03
|
||||
glow_blend_mode = 0
|
||||
|
||||
[node name="LookAt_IK" type="Spatial"]
|
||||
[node name="LookAtIK" type="Spatial"]
|
||||
|
||||
[node name="Floor_plane" type="MeshInstance" parent="."]
|
||||
[node name="Floor" type="MeshInstance" parent="."]
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = SubResource( 2 )
|
||||
|
||||
@@ -66,64 +66,33 @@ script = ExtResource( 5 )
|
||||
MOVEMENT_SPEED = -3.0
|
||||
flip_axis = true
|
||||
|
||||
[node name="targets" type="Spatial" parent="Camera"]
|
||||
[node name="Targets" type="Spatial" parent="Camera"]
|
||||
|
||||
[node name="IK_LookAt_Head" type="Spatial" parent="Camera/targets"]
|
||||
[node name="IK_LookAt_Head" type="Spatial" parent="Camera/Targets"]
|
||||
script = ExtResource( 6 )
|
||||
__meta__ = {
|
||||
"_editor_icon": ExtResource( 7 )
|
||||
}
|
||||
skeleton_path = NodePath("../../../BattleBot/Armature/Skeleton")
|
||||
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 )
|
||||
position_using_additional_bone = false
|
||||
additional_bone_name = ""
|
||||
additional_bone_length = 1.0
|
||||
debug_messages = false
|
||||
|
||||
[node name="IK_LookAt_LeftArm" type="Spatial" parent="Camera/targets"]
|
||||
[node name="IK_LookAt_LeftArm" type="Spatial" parent="Camera/Targets"]
|
||||
script = ExtResource( 6 )
|
||||
__meta__ = {
|
||||
"_editor_icon": ExtResource( 7 )
|
||||
}
|
||||
skeleton_path = NodePath("../../../BattleBot/Armature/Skeleton")
|
||||
bone_name = "Left_UpperArm"
|
||||
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 )
|
||||
position_using_additional_bone = false
|
||||
additional_bone_name = ""
|
||||
additional_bone_length = 1.0
|
||||
debug_messages = false
|
||||
|
||||
[node name="IK_LookAt_RightArm" type="Spatial" parent="Camera/targets"]
|
||||
[node name="IK_LookAt_RightArm" type="Spatial" parent="Camera/Targets"]
|
||||
script = ExtResource( 6 )
|
||||
__meta__ = {
|
||||
"_editor_icon": ExtResource( 7 )
|
||||
}
|
||||
skeleton_path = NodePath("../../../BattleBot/Armature/Skeleton")
|
||||
bone_name = "Right_UpperArm"
|
||||
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, 180 )
|
||||
position_using_additional_bone = false
|
||||
additional_bone_name = ""
|
||||
additional_bone_length = 1.0
|
||||
debug_messages = false
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
anchor_right = 1.0
|
||||
@@ -156,7 +125,7 @@ Move mouse to move IK targets"
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="Button_Next" type="Button" parent="Control"]
|
||||
[node name="ButtonNext" type="Button" parent="Control"]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
|
||||
@@ -49,9 +49,9 @@ size = Vector3( 1, 1, 1 )
|
||||
albedo_color = Color( 0, 0.191406, 0.765625, 1 )
|
||||
roughness = 0.0
|
||||
|
||||
[node name="Skeleton_IK" type="Spatial"]
|
||||
[node name="SkeletonIK" type="Spatial"]
|
||||
|
||||
[node name="Floor_plane" type="MeshInstance" parent="."]
|
||||
[node name="Floor" type="MeshInstance" parent="."]
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = SubResource( 2 )
|
||||
|
||||
@@ -61,28 +61,28 @@ transform = Transform( 0.56827, 0.673454, -0.472789, 0, 0.574581, 0.818448, 0.82
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource( 4 )
|
||||
|
||||
[node name="BattleBot" parent="." instance=ExtResource( 4 )]
|
||||
[node name="GodotBattleBot" parent="." instance=ExtResource( 4 )]
|
||||
|
||||
[node name="godot_battle_bot" parent="BattleBot/Armature/Skeleton" index="0"]
|
||||
[node name="godot_battle_bot" parent="GodotBattleBot/Armature/Skeleton" index="0"]
|
||||
material/0 = ExtResource( 6 )
|
||||
material/1 = ExtResource( 7 )
|
||||
|
||||
[node name="SkeletonIK_Left" type="SkeletonIK" parent="BattleBot/Armature/Skeleton" index="1"]
|
||||
[node name="SkeletonIK_Left" type="SkeletonIK" parent="GodotBattleBot/Armature/Skeleton" index="1"]
|
||||
process_priority = 1
|
||||
root_bone = "Left_UpperArm"
|
||||
tip_bone = "Left_Hand"
|
||||
use_magnet = true
|
||||
magnet = Vector3( 8, 6, 0 )
|
||||
target_node = NodePath("../../../../Camera/targets/Target_Left")
|
||||
target_node = NodePath("../../../../Camera/Targets/TargetLeft")
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="SkeletonIK_Right" type="SkeletonIK" parent="BattleBot/Armature/Skeleton" index="2"]
|
||||
[node name="SkeletonIK_Right" type="SkeletonIK" parent="GodotBattleBot/Armature/Skeleton" index="2"]
|
||||
process_priority = 1
|
||||
root_bone = "Right_UpperArm"
|
||||
tip_bone = "Right_Hand"
|
||||
use_magnet = true
|
||||
magnet = Vector3( -8, 6, 0 )
|
||||
target_node = NodePath("../../../../Camera/targets/Target_Right")
|
||||
target_node = NodePath("../../../../Camera/Targets/TargetRight")
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Camera" type="Camera" parent="."]
|
||||
@@ -92,36 +92,26 @@ script = ExtResource( 5 )
|
||||
MOVEMENT_SPEED = -8.0
|
||||
flip_axis = true
|
||||
|
||||
[node name="targets" type="Spatial" parent="Camera"]
|
||||
[node name="Targets" type="Spatial" parent="Camera"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -8 )
|
||||
|
||||
[node name="IK_LookAt_Head" type="Spatial" parent="Camera/targets"]
|
||||
[node name="IK_LookAt_Head" type="Spatial" parent="Camera/Targets"]
|
||||
script = ExtResource( 9 )
|
||||
__meta__ = {
|
||||
"_editor_icon": ExtResource( 2 )
|
||||
}
|
||||
skeleton_path = NodePath("../../../../Skeleton_IK/BattleBot/Armature/Skeleton")
|
||||
skeleton_path = NodePath("../../../GodotBattleBot/Armature/Skeleton")
|
||||
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 )
|
||||
position_using_additional_bone = false
|
||||
additional_bone_name = ""
|
||||
additional_bone_length = 1.0
|
||||
debug_messages = false
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="Camera/targets"]
|
||||
[node name="1MeterCube" type="MeshInstance" parent="Camera/Targets"]
|
||||
mesh = SubResource( 5 )
|
||||
material/0 = SubResource( 6 )
|
||||
|
||||
[node name="Target_Left" type="Position3D" parent="Camera/targets"]
|
||||
[node name="TargetLeft" type="Position3D" parent="Camera/Targets"]
|
||||
transform = Transform( -0.179447, 0.98366, -0.0145678, 0.981822, 0.178142, -0.0654973, -0.0618319, -0.0260563, -0.997746, 0.653517, -0.112305, -0.760886 )
|
||||
|
||||
[node name="Target_Right" type="Position3D" parent="Camera/targets"]
|
||||
[node name="TargetRight" type="Position3D" parent="Camera/Targets"]
|
||||
transform = Transform( -0.0217688, 0.998559, -0.0490576, 0.992503, 0.0274873, 0.119085, 0.120262, -0.0460975, -0.991671, -0.683053, 0.0251284, -0.811513 )
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
@@ -158,7 +148,7 @@ __meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Button_Next" type="Button" parent="Control"]
|
||||
[node name="ButtonNext" type="Button" parent="Control"]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
@@ -169,9 +159,12 @@ margin_right = -5.0
|
||||
margin_bottom = -10.0
|
||||
text = "Next scene"
|
||||
script = ExtResource( 8 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
scene_to_change_to = "res://fps/fps_example.tscn"
|
||||
|
||||
[node name="Button_Prev" type="Button" parent="Control"]
|
||||
[node name="ButtonPrev" type="Button" parent="Control"]
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
@@ -180,6 +173,9 @@ margin_right = 129.0
|
||||
margin_bottom = -10.0
|
||||
text = "Previous scene"
|
||||
script = ExtResource( 8 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
scene_to_change_to = "res://fabrik_ik.tscn"
|
||||
|
||||
[editable path="BattleBot"]
|
||||
[editable path="GodotBattleBot"]
|
||||
|
||||
@@ -3,19 +3,15 @@ extends Camera
|
||||
export(float) var MOVEMENT_SPEED = 12
|
||||
export(bool) var flip_axis = false
|
||||
|
||||
var targets = null
|
||||
|
||||
|
||||
func _ready():
|
||||
targets = get_node("targets")
|
||||
onready var targets = $Targets
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
var mouse_to_world = project_local_ray_normal(get_viewport().get_mouse_position()) * MOVEMENT_SPEED
|
||||
|
||||
if flip_axis == false:
|
||||
mouse_to_world.z *= -1
|
||||
else:
|
||||
if flip_axis:
|
||||
mouse_to_world = -mouse_to_world
|
||||
else:
|
||||
mouse_to_world.z *= -1
|
||||
|
||||
targets.transform.origin = mouse_to_world
|
||||
|
||||
Reference in New Issue
Block a user