Fix the shooting modifier
This commit is contained in:
parent
0215dcbb13
commit
79043e11e5
godot/src/scenes
@ -20,3 +20,7 @@ transform = Transform3D(1, 0, 0, 0, 0.0224081, 0.999749, 0, -0.999749, 0.0224081
|
||||
[node name="Objects" type="Node3D" parent="."]
|
||||
|
||||
[node name="PlayerController" parent="." instance=ExtResource("2_hem5n")]
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 2.31299, 0, 0, 0, 2.66876, 0, 1.15303, -3.26361)
|
||||
use_collision = true
|
||||
|
@ -24,37 +24,30 @@ func _process_modification() -> void:
|
||||
if bone_idx == -1:
|
||||
return
|
||||
|
||||
var target_position = look_raycast.get_collision_point() if look_raycast.is_colliding() else look_raycast.global_transform.origin + look_raycast.global_transform.basis.z * 30
|
||||
var target_position = look_raycast.get_collision_point() if look_raycast.is_colliding() else look_raycast.global_transform.origin + - look_raycast.global_transform.basis.z * 30
|
||||
var target_position_local = to_local(target_position)
|
||||
aim_raycast.= target_position
|
||||
print(target_position_local)
|
||||
#aim_raycast.= target_position
|
||||
|
||||
var bone_pose = skeleton.get_bone_global_pose(bone_idx)
|
||||
#print(new_basis)
|
||||
|
||||
#skeleton.set_bone_global_pose(bone_idx, Transform3D(bone_pose.basis, bone_pose.origin + Vector3(0, 0, 1)))
|
||||
var gun_position = aim_raycast.global_transform.origin
|
||||
var gun_direction = (target_position - gun_position).normalized()
|
||||
if aiming:
|
||||
var new_pose = bone_pose.looking_at(target_position_local, Vector3.FORWARD, true)
|
||||
var new_basis: Basis
|
||||
new_basis.y = new_pose.basis.z
|
||||
#new_basis.y.y = -new_basis.y.y
|
||||
new_basis.z = new_pose.basis.x
|
||||
new_basis.x = new_pose.basis.y
|
||||
new_pose.basis = new_basis
|
||||
|
||||
skeleton.set_bone_global_pose(bone_idx, new_pose)
|
||||
|
||||
|
||||
func z_and_y_inverse(v : Vector3) -> Vector3 :
|
||||
var tmp: float = v.x
|
||||
v.x = v.y
|
||||
v.y = tmp
|
||||
return v
|
||||
|
||||
#var aim_position = aim_raycast.get_collision_point() if aim_raycast.is_colliding() else aim_raycast.global_transform.origin + aim_raycast.global_transform.basis.z * 20
|
||||
#var aim_position_local = to_local(aim_position)
|
||||
#var direction = (target_position_local - to_local(aim_raycast.global_transform.origin)).normalized()
|
||||
#var new_transform = Transform3D().looking_at(target_position_local, Vector3.UP)
|
||||
#skeleton.set_bone_pose_rotation(bone, new_transform.basis.get_euler())
|
||||
|
||||
#var gun_position = aim_raycast.global_transform.origin
|
||||
#var gun_direction = (target_position - gun_position).normalized()
|
||||
#if aiming:
|
||||
#var new_pose = upper_arm_transform.looking_at(target_position, Vector3.FORWARD, true)
|
||||
#var new_basis: Basis
|
||||
#new_basis.y = new_pose.basis.y
|
||||
#new_basis.y.y = -new_basis.y.y
|
||||
#new_basis.z = new_pose.basis.z
|
||||
#new_basis.x = new_pose.basis.x
|
||||
#new_pose.basis = new_basis
|
||||
#
|
||||
#skeleton.set_bone_global_pose(bone_idx, new_pose)
|
||||
|
@ -1,10 +1,11 @@
|
||||
[gd_scene load_steps=42 format=4 uid="uid://b2ogo643mvror"]
|
||||
[gd_scene load_steps=43 format=4 uid="uid://b2ogo643mvror"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://db5kuorgtnsmg" path="res://src/scenes/player/player.gd" id="1_ytbry"]
|
||||
[ext_resource type="Script" uid="uid://cqk3cp4t6sg1l" path="res://src/camera/camera_mount/camera_mount.gd" id="2_7uvid"]
|
||||
[ext_resource type="Script" uid="uid://fhu1ep8ym4ch" path="res://src/scenes/player/player_movement.gd" id="2_300um"]
|
||||
[ext_resource type="Script" uid="uid://y6hg3gyagmjh" path="res://src/scenes/player/look_forward_modifier.gd" id="2_hfvys"]
|
||||
[ext_resource type="Script" uid="uid://tf0b0xiedgvx" path="res://src/scenes/player/visuals_controller.gd" id="4_2fh3g"]
|
||||
[ext_resource type="Script" uid="uid://bbnh6vbh5cvtq" path="res://src/scenes/player/aiming_modifier.gd" id="5_lh6av"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_4kq8i"]
|
||||
radius = 0.4
|
||||
@ -3414,13 +3415,38 @@ use_magnet = true
|
||||
target_node = NodePath("../../../../Weapon/Ak-47/SecondHand")
|
||||
max_iterations = 1
|
||||
|
||||
[node name="AimingModifier" type="SkeletonModifier3D" parent="VisualsController/Model/Armature/Skeleton3D" node_paths=PackedStringArray("look_raycast", "aim_raycast")]
|
||||
_import_path = NodePath("")
|
||||
unique_name_in_owner = false
|
||||
process_mode = 0
|
||||
process_priority = 0
|
||||
process_physics_priority = 0
|
||||
process_thread_group = 0
|
||||
physics_interpolation_mode = 0
|
||||
auto_translate_mode = 0
|
||||
editor_description = ""
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
|
||||
rotation_edit_mode = 0
|
||||
rotation_order = 2
|
||||
top_level = false
|
||||
visible = true
|
||||
visibility_parent = NodePath("")
|
||||
active = true
|
||||
influence = 1.0
|
||||
script = ExtResource("5_lh6av")
|
||||
look_raycast = NodePath("../../../../Camera/CameraMount/Camera3D/RayCast3D")
|
||||
aim_raycast = NodePath("../../../../Weapon/Ak-47/RayCast3D")
|
||||
bone = "mixamorig_RightHand"
|
||||
aiming = true
|
||||
metadata/_custom_type_script = "uid://bbnh6vbh5cvtq"
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="VisualsController/Model"]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_2wvud")
|
||||
}
|
||||
|
||||
[node name="Weapon" type="BoneAttachment3D" parent="VisualsController"]
|
||||
transform = Transform3D(0.101862, -0.0272939, -0.994332, 0.989693, 0.103634, 0.098543, 0.100361, -0.994155, 0.037569, 0.143142, 1.33176, -0.191155)
|
||||
transform = Transform3D(0.0508198, -0.0186759, -0.998443, 0.997092, 0.0573049, 0.0496806, 0.0562901, -0.998096, 0.0215334, 0.143142, 1.33176, -0.191155)
|
||||
bone_name = "mixamorig_RightHand"
|
||||
bone_idx = 34
|
||||
use_external_skeleton = true
|
||||
@ -3513,7 +3539,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.156969, -0.0748217, 0)
|
||||
transform = Transform3D(-0.959214, -0.192555, -0.206956, -0.229, 0.958549, 0.169536, 0.165733, 0.210014, -0.963549, 0.172895, -0.00541341, 0)
|
||||
|
||||
[node name="Camera" type="BoneAttachment3D" parent="VisualsController"]
|
||||
transform = Transform3D(-0.999896, 2.67307e-05, -0.00528184, 2.30838e-10, 0.999959, 0.00511401, 0.00528105, 0.00511401, -0.999887, 0.0645052, 1.5075, -0.0727705)
|
||||
transform = Transform3D(-0.999896, 2.67307e-05, -0.00528184, 2.30838e-10, 0.999959, 0.00511401, 0.00528105, 0.00511401, -0.999887, 0.0645052, 1.5075, -0.0727704)
|
||||
bone_name = "mixamorig_Head"
|
||||
bone_idx = 5
|
||||
use_external_skeleton = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user