its better now*= decline
This commit is contained in:
parent
e1789160d4
commit
3a7febe17a
@ -1,32 +1,48 @@
|
||||
extends Spatial
|
||||
|
||||
const ROT_MOD = 10
|
||||
|
||||
const ROT_MOD = 500
|
||||
const ROT_DECLINE = 0.1
|
||||
|
||||
var _viewRot = false
|
||||
var _prev_mouse_pos
|
||||
|
||||
var _velx = 0
|
||||
var _vely = 0
|
||||
|
||||
var _torso : RigidBody
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
PhysicsServer.area_set_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY, 0)
|
||||
_torso = get_node("Torso")
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
func _process(delta):
|
||||
if _viewRot:
|
||||
var mouse_pos = get_viewport().get_mouse_position()
|
||||
|
||||
var x_dif = mouse_pos.x - _prev_mouse_pos.x
|
||||
var y_dif = mouse_pos.y - _prev_mouse_pos.y
|
||||
|
||||
print (x_dif)
|
||||
print (y_dif)
|
||||
|
||||
rotate_x(x_dif * ROT_MOD * delta * PI/180 - global_transform.basis.get_euler().y)
|
||||
rotate_y(y_dif * ROT_MOD * delta * PI/180 - global_transform.basis.get_euler().y)
|
||||
_velx = (mouse_pos.x - _prev_mouse_pos.x) * delta
|
||||
_vely = (mouse_pos.y - _prev_mouse_pos.y) * delta
|
||||
|
||||
_prev_mouse_pos = mouse_pos
|
||||
|
||||
if not(_velx < 0.001 and _velx > -0.001) or not(_vely < 0.001 and _vely > -0.001) or _viewRot:
|
||||
_torso.rotate_x(_vely * ROT_MOD * delta * PI/180 - global_transform.basis.get_euler().x)
|
||||
_torso.rotate_y(_velx * ROT_MOD * delta * PI/180 - global_transform.basis.get_euler().y)
|
||||
|
||||
var decline = (1 - ROT_DECLINE * (delta*100))
|
||||
|
||||
if decline > 1:
|
||||
decline = 1
|
||||
elif decline < 0:
|
||||
decline = 0
|
||||
|
||||
_velx *= decline
|
||||
_vely *= decline
|
||||
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
pass
|
||||
# Get the camera
|
||||
#var camera = get_node("GUI/HBoxC/ViewportContainer/Viewport/Camera")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user