extends KinematicBody
-const SPEED = 20
+const SPEED_FORWARD = 5
+const SPEED_TURN = 60
+const SPEED_AIM = PI / 4
+const FRICTION = 0.99
var velocity = Vector3()
pass # Replace with function body.
func get_player_input(delta):
- var cam_vec_lateral = $Camera.transform.basis.x
- var cam_vec_vertical = $Camera.transform.basis.y
+ var vec_lateral = transform.basis.x
+ var vec_vertical = transform.basis.y
if Input.is_action_pressed("player_left"):
- velocity += SPEED * cam_vec_lateral * delta
+ velocity += SPEED_TURN * -vec_lateral * delta
elif Input.is_action_pressed("player_right"):
- velocity += SPEED * -cam_vec_lateral * delta
+ velocity += SPEED_TURN * vec_lateral * delta
if Input.is_action_pressed("player_up"):
- velocity += SPEED * cam_vec_vertical * delta
+ velocity += SPEED_TURN * vec_vertical * delta
elif Input.is_action_pressed("player_down"):
- velocity += SPEED * -cam_vec_vertical * delta
+ velocity += SPEED_TURN * -vec_vertical * delta
+
+ if Input.is_action_pressed("player_aim_up"):
+ rotate_x(SPEED_AIM * delta)
+ elif Input.is_action_pressed("player_aim_down"):
+ rotate_x(-SPEED_AIM * delta)
+ if Input.is_action_pressed("player_aim_left"):
+ rotate_y(SPEED_AIM * delta)
+ elif Input.is_action_pressed("player_aim_right"):
+ rotate_y(-SPEED_AIM * delta)
-func _process(delta):
- # move foward according to the camera's POV
- var cam_vec_forward = $Camera.transform.basis.z
- velocity += SPEED * -cam_vec_forward * delta
+func _process(delta):
# get velocity changes player asks for
get_player_input(delta)
+ velocity.x *= FRICTION
+ velocity.y *= FRICTION
-func _physics_process(_delta):
+ # move foward according to the camera's POV
+ var vec_forward = transform.basis.z
+ velocity += SPEED_FORWARD * -vec_forward * delta
+
+func _physics_process(delta):
velocity = move_and_slide(velocity, Vector3.UP)
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.371765, -0.470031 )
shape = SubResource( 5 )
-[node name="Camera" type="Camera" parent="."]
+[node name="camera_pivot" type="Spatial" parent="."]
+
+[node name="Camera" type="Camera" parent="camera_pivot"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 13.3084 )
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":7,"pressure":0.0,"pressed":false,"script":null)
]
}
+player_aim_up={
+"deadzone": 0.5,
+"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":3,"axis_value":-1.0,"script":null)
+ ]
+}
+player_aim_down={
+"deadzone": 0.5,
+"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":3,"axis_value":1.0,"script":null)
+ ]
+}
+player_aim_left={
+"deadzone": 0.5,
+"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":2,"axis_value":-1.0,"script":null)
+ ]
+}
+player_aim_right={
+"deadzone": 0.5,
+"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":2,"axis_value":1.0,"script":null)
+ ]
+}
[physics]