Открыть боковую панель
Левадный Владимир Юрьевич
universo-godot
Коммиты
4b720d4d
Коммит
4b720d4d
создал
Июн 27, 2020
по автору
magcourier
Просмотр файлов
Устранение проблем с ПКМ в космосе
владелец
e2ad3ed9
Изменения
4
Скрыть пробелы
Построчно
Рядом
blokoj/kosmo/skriptoj/main_camera.gd
Просмотр файла @
4b720d4d
...
...
@@ -2,6 +2,7 @@ extends Camera
var
point_of_interest
# к чему привязать камеру
var
choose
=
false
# привязать или отвязать камеру
var
right_click_mode
:
bool
=
false
export
var
enabled
=
true
setget
set_enabled
export
(
int
,
"Visible"
,
"Hidden"
,
"Captured, Confined"
)
var
mouse_mode
=
2
...
...
@@ -25,7 +26,7 @@ export var distance_step: float = 2.0
# Movement settings
export
(
float
,
0.0
,
1.0
)
var
acceleration
=
0.1
export
(
float
,
0.0
,
0.0
,
1.0
)
var
deceleration
=
0.1
export
var
max_speed
=
Vector3
(
1.0
,
1.0
,
1.0
)
export
var
max_speed
=
Vector3
(
1
00
.0
,
1
00
.0
,
1
00
.0
)
export
var
local
=
true
# Intern variables.
...
...
@@ -54,17 +55,20 @@ func _ready():
#
Input
.
set_mouse_mode
(
Input
.
MOUSE_MODE_CONFINED
)
#func _input(event):
func
_unhandled_input
(
event
):
if
freelook
:
if
Input
.
get_action_strength
(
"right_click"
):
if
Input
.
is_action_just_pressed
(
"right_click"
):
right_click_mode
=
true
;
Input
.
set_mouse_mode
(
Input
.
MOUSE_MODE_CAPTURED
)
if
Input
.
is_action_just_released
(
"right_click"
):
right_click_mode
=
false
;
Input
.
set_mouse_mode
(
Input
.
MOUSE_MODE_VISIBLE
)
if
right_click_mode
:
if
event
is
InputEventMouseMotion
:
_mouse_offset
=
event
.
relative
else
:
Input
.
set_mouse_mode
(
Input
.
MOUSE_MODE_VISIBLE
)
func
_input
(
event
):
if
Input
.
is_action_just_pressed
(
"ui_select"
):
choose
=!
choose
if
choose
:
...
...
@@ -77,17 +81,12 @@ func _input(event):
distance
-=
distance_step
if
event
.
is_action_pressed
(
"wheel_up"
):
distance
+=
distance_step
distance
+=
(
Input
.
get_action_strength
(
"ui_down"
)
-
Input
.
get_action_strength
(
"ui_up"
))
*
distance_step
*
0.5
distance
=
clamp
(
distance
,
distance_min
,
distance_max
)
else
:
_direction
.
x
=
Input
.
get_action_strength
(
"ui_right"
)
-
Input
.
get_action_strength
(
"ui_left"
)
_direction
.
y
=
Input
.
get_action_strength
(
"ui_page_up"
)
-
Input
.
get_action_strength
(
"ui_page_down"
)
_direction
.
z
=
Input
.
get_action_strength
(
"ui_down"
)
-
Input
.
get_action_strength
(
"ui_up"
)
func
_physics_process
(
delta
):
collide
()
if
privot
:
distance
+=
(
Input
.
get_action_strength
(
"ui_down"
)
-
Input
.
get_action_strength
(
"ui_up"
))
*
distance_step
*
0.1
distance
=
clamp
(
distance
,
distance_min
,
distance_max
)
distance_smooth
=
lerp
(
distance_smooth
,
distance
,
0.05
)
set_translation
(
privot
.
get_translation
())
translate_object_local
(
Vector3
(
0.0
,
0.0
,
distance_smooth
))
...
...
@@ -125,6 +124,12 @@ func collide():
_direction
.
z
=-
2
func
_update_movement
(
delta
):
if
!
privot
:
_direction
.
x
=
Input
.
get_action_strength
(
"ui_right"
)
-
Input
.
get_action_strength
(
"ui_left"
)
_direction
.
y
=
Input
.
get_action_strength
(
"ui_page_up"
)
-
Input
.
get_action_strength
(
"ui_page_down"
)
_direction
.
z
=
Input
.
get_action_strength
(
"ui_down"
)
-
Input
.
get_action_strength
(
"ui_up"
)
else
:
_direction
=
Vector3
.
ZERO
var
offset
=
max_speed
*
acceleration
*
_direction
_speed
.
x
=
clamp
(
_speed
.
x
+
offset
.
x
,
-
max_speed
.
x
,
max_speed
.
x
)
...
...
@@ -146,6 +151,9 @@ func _update_movement(delta):
# warning-ignore:unused_argument
func
_update_rotation
(
delta
):
if
privot
:
_mouse_offset
.
x
-=
Input
.
get_action_strength
(
"ui_right"
)
-
Input
.
get_action_strength
(
"ui_left"
)
_mouse_offset
.
y
+=
Input
.
get_action_strength
(
"ui_page_up"
)
-
Input
.
get_action_strength
(
"ui_page_down"
)
var
offset
=
Vector2
();
offset
+=
_mouse_offset
*
sensitivity
_mouse_offset
=
Vector2
()
...
...
@@ -181,5 +189,3 @@ func set_enabled(value):
func
set_smoothness
(
value
):
smoothness
=
clamp
(
value
,
0.001
,
0.999
)
blokoj/kosmo/skriptoj/space.gd
Просмотр файла @
4b720d4d
...
...
@@ -41,7 +41,7 @@ func _ready():
$
camera
.
point_of_interest
=
ship
for
i
in
get_children
():
if
has_signal
(
i
,
"new_way_point"
):
if
has_signal
_custom
(
i
,
"new_way_point"
):
i
.
connect
(
"new_way_point"
,
self
,
"set_way_point"
)
subscribtion_kubo
()
...
...
@@ -147,11 +147,10 @@ func subscribtion_kubo():
# #запускаем таймер
# $timer.start()
func
has_signal
(
node
,
sgnl
):
func
has_signal
_custom
(
node
,
sgnl
)
->
bool
:
if
node
==
null
:
return
false
node
=
node
.
get_signal_list
()
for
i
in
node
:
for
i
in
node
.
get_signal_list
():
if
i
.
name
==
sgnl
:
return
true
return
false
...
...
blokoj/rajtigo/rajtigo.gd
Просмотр файла @
4b720d4d
...
...
@@ -5,6 +5,20 @@ extends Control
func
_enter_tree
():
# Прячем глобальную сцену с меню
Title
.
set_visible
(
false
)
# счтываем файл настроек и проверяем - может запущен серверный клиент
# var config = ConfigFile.new()
# var err = config.load("user://settings.cfg")
# if err == OK:
# Global.server = config.get_value("global", "server", false)
# else:
# config.set_value('global','server',true)
# config.set_value('kosmo','kube',1)
# config.set_value('aliro','user','server')
# config.set_value('aliro','password','12345678')
# config.save("user://settings.cfg")
# Скрываем символы в поле для ввода пароля
$
Control
/
your_password
.
set_secret
(
true
)
...
...
project.godot
Просмотр файла @
4b720d4d
...
...
@@ -34,6 +34,11 @@ Global="*res://kerno/skriptoj/global.gd"
Title="*res://kerno/menuo/menuo.tscn"
Net="*res://kerno/skriptoj/network.gd"
[display]
window/stretch/mode="2d"
window/stretch/aspect="keep_width"
[gui]
theme/custom_font="res://kerno/menuo/resursoj/fonts/new_dynamicfont.tres"
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать