blob: dd5b1770650f519936b79692f2ce00379465fa3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
extends Spatial
var m = SpatialMaterial.new()
var winddir = Vector3(1,0,0)
onready var pathfinder = get_node("PLAYERS/Player2")
var path = []
var map_rid
var client_id
var player_char
var players_info = {}
# Called when the node enters the scene tree for the first time.
func _ready():
map_rid = NavigationServer.get_maps()
print(map_rid)
for rid in map_rid:
NavigationServer.map_set_edge_connection_margin(rid,1)
m.flags_unshaded = true
m.flags_use_point_size = true
m.albedo_color = Color.white
remotesync func update_players_info(info):
players_info = info
remote func _call_on_server(function, arguments):
print('Remote server call: ' + function)
$Server.call(function, arguments)
func find_path(to):
pathfinder.nav.set_target_location(to)
var t_path = pathfinder.nav.get_next_location()
pathfinder.should_move = true
t_path = pathfinder.nav.get_nav_path()
print(to)
print(t_path)
draw_path(t_path)
pass
func draw_path(path_array):
var im = get_node("Draw")
im.set_material_override(m)
im.clear()
im.begin(Mesh.PRIMITIVE_POINTS, null)
im.add_vertex(path_array[0])
im.add_vertex(path_array[path_array.size() - 1])
im.end()
im.begin(Mesh.PRIMITIVE_LINE_STRIP, null)
for x in path_array:
im.add_vertex(x)
im.end()
|