Recoil system
This commit is contained in:
parent
1c062489b1
commit
cdfce4c7db
11 changed files with 144 additions and 8 deletions
BIN
models/molikman_ingame.glb
Normal file
BIN
models/molikman_ingame.glb
Normal file
Binary file not shown.
42
models/molikman_ingame.glb.import
Normal file
42
models/molikman_ingame.glb.import
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://c2r8dbudbs7l3"
|
||||||
|
path="res://.godot/imported/molikman_ingame.glb-dc1d9902b7bc622e5bda8fed04560710.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://models/molikman_ingame.glb"
|
||||||
|
dest_files=["res://.godot/imported/molikman_ingame.glb-dc1d9902b7bc622e5bda8fed04560710.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
BIN
models/molikman_ingame_tex_Molikman.png
Normal file
BIN
models/molikman_ingame_tex_Molikman.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 461 KiB |
44
models/molikman_ingame_tex_Molikman.png.import
Normal file
44
models/molikman_ingame_tex_Molikman.png.import
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bfc7syqoe06pt"
|
||||||
|
path.s3tc="res://.godot/imported/molikman_ingame_tex_Molikman.png-5702ec26cbf18695fea633cff99e732a.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
generator_parameters={
|
||||||
|
"md5": "adf17223cdac27afac207ae40df37427"
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://models/molikman_ingame_tex_Molikman.png"
|
||||||
|
dest_files=["res://.godot/imported/molikman_ingame_tex_Molikman.png-5702ec26cbf18695fea633cff99e732a.s3tc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=2
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=true
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=0
|
||||||
|
|
@ -21,6 +21,12 @@ PlayerGlobal="*res://scripts/player/player_global.gd"
|
||||||
Lobby="*res://scripts/multiplayer/lobby.gd"
|
Lobby="*res://scripts/multiplayer/lobby.gd"
|
||||||
Session="*res://scripts/multiplayer/session.gd"
|
Session="*res://scripts/multiplayer/session.gd"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/viewport_width=1280
|
||||||
|
window/size/viewport_height=720
|
||||||
|
window/stretch/mode="viewport"
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
plr_forward={
|
plr_forward={
|
||||||
|
|
|
||||||
|
|
@ -130,10 +130,12 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
shape = SubResource("CapsuleShape3D_u8vuu")
|
shape = SubResource("CapsuleShape3D_u8vuu")
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="."]
|
[node name="Camera3D" type="Camera3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 2, 0)
|
||||||
cull_mask = 1048573
|
cull_mask = 1048573
|
||||||
fov = 90.0
|
fov = 90.0
|
||||||
script = ExtResource("3_qhqgy")
|
script = ExtResource("3_qhqgy")
|
||||||
|
compensation_time = 0.1
|
||||||
|
compensation_delay = 0.1
|
||||||
|
|
||||||
[node name="molikman_hands" parent="Camera3D" instance=ExtResource("4_dqkch")]
|
[node name="molikman_hands" parent="Camera3D" instance=ExtResource("4_dqkch")]
|
||||||
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, -1, 0)
|
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, -1, 0)
|
||||||
|
|
@ -248,10 +250,11 @@ crosses_offset = 3.0
|
||||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||||
replication_config = SubResource("SceneReplicationConfig_qhqgy")
|
replication_config = SubResource("SceneReplicationConfig_qhqgy")
|
||||||
|
|
||||||
[node name="WeaponSystem" type="Node" parent="." node_paths=PackedStringArray("default_pistol", "animation_player")]
|
[node name="WeaponSystem" type="Node" parent="." node_paths=PackedStringArray("default_pistol", "animation_player", "camera")]
|
||||||
script = ExtResource("4_qlg0r")
|
script = ExtResource("4_qlg0r")
|
||||||
default_pistol = NodePath("StartingPistol")
|
default_pistol = NodePath("StartingPistol")
|
||||||
animation_player = NodePath("../Camera3D/molikman_hands/AnimationPlayer")
|
animation_player = NodePath("../Camera3D/molikman_hands/AnimationPlayer")
|
||||||
|
camera = NodePath("../Camera3D")
|
||||||
|
|
||||||
[node name="StartingPistol" parent="WeaponSystem" instance=ExtResource("7_fjrip")]
|
[node name="StartingPistol" parent="WeaponSystem" instance=ExtResource("7_fjrip")]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
# Get the input direction and handle the movement/deceleration.
|
# Get the input direction and handle the movement/deceleration.
|
||||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||||
var input_dir := Input.get_vector("plr_strafe_l", "plr_strafe_r", "plr_forward", "plr_back")
|
var input_dir := Input.get_vector("plr_strafe_r","plr_strafe_l", "plr_back","plr_forward")
|
||||||
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||||
if direction:
|
if direction:
|
||||||
velocity.x = direction.x * SPEED
|
velocity.x = direction.x * SPEED
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,59 @@
|
||||||
extends Camera3D
|
extends Camera3D
|
||||||
|
|
||||||
const COLLINEAR = 1.5707963267948966
|
class_name PlayerCamera
|
||||||
|
|
||||||
@export var SENSITIVITY = 0.02
|
@export var SENSITIVITY = 0.02
|
||||||
|
|
||||||
|
|
||||||
|
var vertical_compensation : float
|
||||||
|
var compensation_tween: Tween
|
||||||
|
var compensate: bool = false
|
||||||
|
var compensation_speed: float
|
||||||
|
@export var compensation_time: float = 1.0
|
||||||
|
@export var compensation_delay: float = 0.5
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
func _enter_tree() -> void:
|
||||||
set_multiplayer_authority(get_parent().name.to_int())
|
set_multiplayer_authority(get_parent().name.to_int())
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
# Move to level controller when possible
|
# Move to level controller when possible
|
||||||
#Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
#Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
if not is_multiplayer_authority():
|
if not is_multiplayer_authority():
|
||||||
return
|
return
|
||||||
current = true
|
current = true
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if compensate:
|
||||||
|
if abs(vertical_compensation) <= 0.001:
|
||||||
|
vertical_compensation = 0
|
||||||
|
compensate = false
|
||||||
|
return
|
||||||
|
rotate_camera(0,compensation_speed * delta)
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if not is_multiplayer_authority():
|
if not is_multiplayer_authority():
|
||||||
return
|
return
|
||||||
if event is InputEventMouseMotion:
|
if event is InputEventMouseMotion:
|
||||||
get_parent().rotate_y(-event.relative.x * SENSITIVITY)
|
rotate_camera(-event.relative.x * SENSITIVITY,-event.relative.y * SENSITIVITY)
|
||||||
rotate_x(-event.relative.y * SENSITIVITY)
|
|
||||||
rotation.x = clamp(rotation.x,-COLLINEAR,COLLINEAR)
|
func rotate_camera(x,y) -> void:
|
||||||
orthonormalize()
|
get_parent().rotate_y(x)
|
||||||
|
rotation.x = clamp(rotation.x + y,-PI/2,PI/2)
|
||||||
|
orthonormalize()
|
||||||
|
if sign(vertical_compensation) == sign(y):
|
||||||
|
vertical_compensation -= y
|
||||||
|
|
||||||
|
func recoil(x,y) -> void:
|
||||||
|
rotate_camera(x,y)
|
||||||
|
vertical_compensation -= y
|
||||||
|
if compensation_tween:
|
||||||
|
compensation_tween.kill()
|
||||||
|
compensation_tween = create_tween()
|
||||||
|
compensation_tween.tween_interval(compensation_delay)
|
||||||
|
compensation_tween.tween_callback(start_compensating)
|
||||||
|
|
||||||
|
func start_compensating() -> void:
|
||||||
|
compensate = true
|
||||||
|
print(vertical_compensation)
|
||||||
|
compensation_speed = vertical_compensation / compensation_time
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ func fire() -> void:
|
||||||
raycast.get_collider().hp -= damage
|
raycast.get_collider().hp -= damage
|
||||||
|
|
||||||
fire_timer.start()
|
fire_timer.start()
|
||||||
|
machine.player_camera.recoil(0,0.1)
|
||||||
|
|
||||||
func with_morphems(animation):
|
func with_morphems(animation):
|
||||||
return machine.animation_prefix + ((animation+"_empty") if emptyable and machine.ammo == 0 else animation)
|
return machine.animation_prefix + ((animation+"_empty") if emptyable and machine.ammo == 0 else animation)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ class_name WeaponSubStateMachine
|
||||||
|
|
||||||
var system: WeaponSystem
|
var system: WeaponSystem
|
||||||
var animation_player: AnimationPlayer
|
var animation_player: AnimationPlayer
|
||||||
|
var player_camera: PlayerCamera
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
for child in get_children():
|
for child in get_children():
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ class_name WeaponSystem
|
||||||
@export var default_knife: WeaponSubStateMachine
|
@export var default_knife: WeaponSubStateMachine
|
||||||
|
|
||||||
@export var animation_player: AnimationPlayer
|
@export var animation_player: AnimationPlayer
|
||||||
|
@export var camera: PlayerCamera
|
||||||
|
|
||||||
var current_state: WeaponSubStateMachine
|
var current_state: WeaponSubStateMachine
|
||||||
|
|
||||||
|
|
@ -27,6 +28,7 @@ func _ready() -> void:
|
||||||
if child is WeaponSubStateMachine:
|
if child is WeaponSubStateMachine:
|
||||||
child.system = self
|
child.system = self
|
||||||
child.animation_player = animation_player
|
child.animation_player = animation_player
|
||||||
|
child.player_camera = camera
|
||||||
else:
|
else:
|
||||||
push_warning("Child of weapon system is not ability or weapon")
|
push_warning("Child of weapon system is not ability or weapon")
|
||||||
|
|
||||||
|
|
@ -46,6 +48,8 @@ func add(state: WeaponSubStateMachine, slot: StringName) -> void:
|
||||||
|
|
||||||
slots[slot] = state
|
slots[slot] = state
|
||||||
state.system = self
|
state.system = self
|
||||||
|
state.animation_player = animation_player
|
||||||
|
state.player_camera = camera
|
||||||
|
|
||||||
|
|
||||||
func switch(to: StringName):
|
func switch(to: StringName):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue