-
Notifications
You must be signed in to change notification settings - Fork 1
/
town_scene.gd
48 lines (40 loc) · 1.35 KB
/
town_scene.gd
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
extends Spatial
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func set_wheel_friction(friction):
var root = get_node("/root")
var car = root.find_node('car', true, false)
var carbody = car.get_node("Body")
var wheel1 = car.get_node("Body/Wheel1")
var wheel2 = car.get_node("Body/Wheel2")
var wheel3 = car.get_node("Body/Wheel3")
var wheel4 = car.get_node("Body/Wheel4")
wheel1.wheel_friction_slip = friction
wheel2.wheel_friction_slip = friction
wheel3.wheel_friction_slip = friction
wheel4.wheel_friction_slip = friction
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if $MuhRayCast.is_colliding():
var collider = $MuhRayCast.get_collider()
match collider.name:
# "Landscape_ice":
# set_wheel_friction(0.2)
"Asphalt":
set_wheel_friction(1)
"Grass":
set_wheel_friction(0.5)
# var mat = colParent.get_surface_material(0)
# var mat1 = colParent.get_surface_material(1)
# if mat1:
# print(mat1.resource_name)
# else:
# print(mat.resource_name)
# print(physicsMatOverride.friction)
# if $MuhRayCast.get_collider().get_node_or_null("MeshInstance"):
# print($MuhRayCast.get_collider().get_node("MeshInstance").mesh.material)
# var asd = 2