- some improvements, beautify code *_*
This commit is contained in:
parent
4d66d64d04
commit
341c8ba2f2
@ -1,10 +1,11 @@
|
||||
extends KinematicBody
|
||||
|
||||
# export variable
|
||||
export(NodePath) var body_nodepath
|
||||
|
||||
# const
|
||||
const GRAVITY = -24.8
|
||||
const JUMP_SPEED = 18
|
||||
const JUMP_SPEED = 8
|
||||
const MOVE_SPEED = 20
|
||||
const SPRINT_SPEED = 40
|
||||
const ACCEL = 4.5
|
||||
@ -12,16 +13,18 @@ const MAX_SLOPE_ANGLE = 40
|
||||
const MOUSE_SENSITIVITY = 0.05
|
||||
|
||||
# private members
|
||||
var _body
|
||||
var _camera
|
||||
var _body: Spatial
|
||||
var _camera: Camera
|
||||
var _dir = Vector3();
|
||||
var _vel = Vector3();
|
||||
var _is_sprinting;
|
||||
|
||||
|
||||
func _ready():
|
||||
_body = $Body
|
||||
_body = get_node(body_nodepath) as Spatial # = $Body
|
||||
assert(null != _body)
|
||||
_camera = $Body/Camera
|
||||
assert(null != _camera)
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
|
||||
@ -49,8 +52,7 @@ func process_input(delta):
|
||||
_dir += camera_transform.basis.x * input_movement_vector.x
|
||||
|
||||
# jumping
|
||||
# TODO: remove after collision is working
|
||||
if Input.is_action_just_pressed("move_jump"): # and is_on_floor():
|
||||
if Input.is_action_just_pressed("move_jump") and is_on_floor():
|
||||
_vel.y = JUMP_SPEED
|
||||
|
||||
# sprinting
|
@ -1,11 +1,12 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Characters/Player/PlayerMovement.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Characters/Player/Player.gd" type="Script" id=1]
|
||||
|
||||
[sub_resource type="CylinderShape" id=1]
|
||||
|
||||
[node name="Player" type="KinematicBody"]
|
||||
script = ExtResource( 1 )
|
||||
body_nodepath = NodePath("Body")
|
||||
|
||||
[node name="Body" type="Spatial" parent="."]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user