Controler Aim
This commit is contained in:
parent
364ec9a959
commit
b45a090d23
4 changed files with 37 additions and 12 deletions
|
@ -1,17 +1,17 @@
|
||||||
[gd_scene load_steps=14 format=3 uid="uid://4fysk8vaw3e1"]
|
[gd_scene load_steps=14 format=3 uid="uid://4fysk8vaw3e1"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/UI/MainMenuManager.gd" id="1_qepq0"]
|
[ext_resource type="Script" path="res://Scripts/UI/MainMenuManager.gd" id="1_qepq0"]
|
||||||
[ext_resource type="Texture2D" uid="uid://tjxkew3m4v8m" path="res://Assets/Sprites/Easter Egg/Shadow.png" id="2_8o6th"]
|
[ext_resource type="Texture2D" uid="uid://tjxkew3m4v8m" path="res://Assets/Sprites/Start Menu Old/Easter Egg/Shadow.png" id="2_8o6th"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c4btepmue6d7p" path="res://Scenes/Game.tscn" id="2_28004"]
|
[ext_resource type="PackedScene" uid="uid://c4btepmue6d7p" path="res://Scenes/Game.tscn" id="2_28004"]
|
||||||
[ext_resource type="Texture2D" uid="uid://daat37cyg0go5" path="res://Assets/Sprites/Easter Egg/Egg 3.png" id="3_1e3fe"]
|
[ext_resource type="Texture2D" uid="uid://daat37cyg0go5" path="res://Assets/Sprites/Start Menu Old/Easter Egg/Egg 3.png" id="3_1e3fe"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cbfcolm6mjolp" path="res://Prefabs/Settings Menu.tscn" id="3_r3r61"]
|
[ext_resource type="PackedScene" uid="uid://cbfcolm6mjolp" path="res://Prefabs/Settings Menu.tscn" id="3_r3r61"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dhvvw4yckl8x7" path="res://Assets/Sprites/Props/Cake.png" id="5_7ull8"]
|
[ext_resource type="Texture2D" uid="uid://dhvvw4yckl8x7" path="res://Assets/Sprites/Start Menu Old/Cake.png" id="5_7ull8"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c3yg6u8yncau3" path="res://Assets/Sprites/Easter Egg/Egg 2.png" id="6_45o7d"]
|
[ext_resource type="Texture2D" uid="uid://c3yg6u8yncau3" path="res://Assets/Sprites/Start Menu Old/Easter Egg/Egg 2.png" id="6_45o7d"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cp84ssaqs3pmp" path="res://Assets/Sprites/UI Elements/Jesus.png" id="6_wnx18"]
|
[ext_resource type="Texture2D" uid="uid://cp84ssaqs3pmp" path="res://Assets/Sprites/Start Menu Old/Jesus.png" id="6_wnx18"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dkotcqflp3e32" path="res://Assets/Sprites/Easter Egg/Egg 1.png" id="7_285vd"]
|
[ext_resource type="Texture2D" uid="uid://dkotcqflp3e32" path="res://Assets/Sprites/Start Menu Old/Easter Egg/Egg 1.png" id="7_285vd"]
|
||||||
[ext_resource type="Theme" uid="uid://o3vg845para" path="res://Assets/UI_Theme.tres" id="8_lr748"]
|
[ext_resource type="Theme" uid="uid://o3vg845para" path="res://Assets/UI_Theme.tres" id="8_lr748"]
|
||||||
[ext_resource type="Script" path="res://Scripts/UI/MenuButton.gd" id="9_2cu5l"]
|
[ext_resource type="Script" path="res://Scripts/UI/MenuButton.gd" id="9_2cu5l"]
|
||||||
[ext_resource type="Texture2D" uid="uid://6snf183fgfo5" path="res://Assets/Sprites/UI Elements/Cross.png" id="12_dhfc0"]
|
[ext_resource type="Texture2D" uid="uid://6snf183fgfo5" path="res://Assets/Sprites/Start Menu Old/Cross.png" id="12_dhfc0"]
|
||||||
[ext_resource type="AudioStream" uid="uid://c6nf5s6xy2uii" path="res://Assets/Temp Music/omw-to-beat-the-big-bad.wav" id="13_3j724"]
|
[ext_resource type="AudioStream" uid="uid://c6nf5s6xy2uii" path="res://Assets/Temp Music/omw-to-beat-the-big-bad.wav" id="13_3j724"]
|
||||||
|
|
||||||
[node name="MainMenu" type="Node" node_paths=PackedStringArray("default_focus")]
|
[node name="MainMenu" type="Node" node_paths=PackedStringArray("default_focus")]
|
||||||
|
|
|
@ -10,10 +10,11 @@ func _physics_process(delta : float):
|
||||||
|
|
||||||
func get_move_input_vector() -> Vector2:
|
func get_move_input_vector() -> Vector2:
|
||||||
var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized()
|
var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized()
|
||||||
var input_direction_controller = Input.get_vector("move_left_controller", "move_right_controller", "move_up_controller", "move_down_controller").normalized()
|
var input_direction_controller = Input.get_vector("move_left_controller", "move_right_controller", "move_up_controller", "move_down_controller")
|
||||||
return input_direction_controller if input_direction_controller.length() > input_direction.length() else input_direction_controller
|
return (input_direction if not input_direction_controller.length() > input_direction.length() else input_direction_controller.normalized())
|
||||||
|
|
||||||
func update_player_movement(delta : float):
|
func update_player_movement(delta : float):
|
||||||
|
print(get_move_input_vector())
|
||||||
var input = get_move_input_vector()
|
var input = get_move_input_vector()
|
||||||
|
|
||||||
# Damp Movement if not moving, Accelerate if Moving
|
# Damp Movement if not moving, Accelerate if Moving
|
||||||
|
|
|
@ -9,9 +9,13 @@ func _process(_delta):
|
||||||
if Input.is_action_just_pressed("attack") or Input.is_action_just_pressed("attack_controller"):
|
if Input.is_action_just_pressed("attack") or Input.is_action_just_pressed("attack_controller"):
|
||||||
spawn_projectile(self.global_position, self.rotation, 350.0, 1)
|
spawn_projectile(self.global_position, self.rotation, 350.0, 1)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func get_aim_pos() -> Vector2:
|
||||||
|
var aim_dir_controller = Input.get_vector("aim_left_controller", "aim_right_controller", "aim_up_controller", "aim_down_controller").normalized()
|
||||||
|
return get_global_mouse_position() if aim_dir_controller.length() == 0 else self.global_position + aim_dir_controller
|
||||||
|
|
||||||
func rotate_to_pointer():
|
func rotate_to_pointer():
|
||||||
look_at(get_global_mouse_position())
|
look_at(get_aim_pos())
|
||||||
#TODO Implement Joystick Aiming
|
#TODO Implement Joystick Aiming
|
||||||
|
|
||||||
func spawn_projectile(pos : Vector2, dir : float, speed: float, damage : int):
|
func spawn_projectile(pos : Vector2, dir : float, speed: float, damage : int):
|
||||||
|
|
|
@ -134,7 +134,27 @@ move_down_controller={
|
||||||
}
|
}
|
||||||
attack_controller={
|
attack_controller={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
aim_left_controller={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
aim_right_controller={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
aim_up_controller={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
aim_down_controller={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue