diff options
Diffstat (limited to 'demos/3d/truck_town')
-rw-r--r-- | demos/3d/truck_town/car_base.scn | bin | 11573 -> 13459 bytes | |||
-rw-r--r-- | demos/3d/truck_town/car_select.gd | 20 | ||||
-rw-r--r-- | demos/3d/truck_town/car_select.scn | bin | 1702 -> 1968 bytes | |||
-rw-r--r-- | demos/3d/truck_town/crane.scn | bin | 24164 -> 26350 bytes | |||
-rw-r--r-- | demos/3d/truck_town/follow_camera.gd | 58 | ||||
-rw-r--r-- | demos/3d/truck_town/trailer_truck.scn | bin | 19934 -> 22400 bytes | |||
-rw-r--r-- | demos/3d/truck_town/truck_scene.scn | bin | 1873575 -> 1889480 bytes | |||
-rw-r--r-- | demos/3d/truck_town/trucktown.scn | bin | 161749 -> 165689 bytes | |||
-rw-r--r-- | demos/3d/truck_town/vehicle.gd | 43 |
9 files changed, 45 insertions, 76 deletions
diff --git a/demos/3d/truck_town/car_base.scn b/demos/3d/truck_town/car_base.scn Binary files differindex d62c8dcb29..acfbfae162 100644 --- a/demos/3d/truck_town/car_base.scn +++ b/demos/3d/truck_town/car_base.scn diff --git a/demos/3d/truck_town/car_select.gd b/demos/3d/truck_town/car_select.gd index 00b4d853b8..4efcf63426 100644 --- a/demos/3d/truck_town/car_select.gd +++ b/demos/3d/truck_town/car_select.gd @@ -1,40 +1,30 @@ extends Control -# member variables here, example: -# var a=2 -# var b="textvar" - -func _ready(): - # Initalization here - pass - -var town=null +# Member variables +var town = null func _back(): - town.queue_free() show() - -func _load_scene(car): +func _load_scene(car): var tt = load(car).instance() tt.set_name("car") town = load("res://truck_scene.scn").instance() town.get_node("instance_pos").add_child(tt) - town.get_node("back").connect("pressed",self,"_back") + town.get_node("back").connect("pressed", self, "_back") get_parent().add_child(town) hide() -func _on_van_1_pressed(): +func _on_van_1_pressed(): _load_scene("res://car_base.scn") func _on_van_2_pressed(): - _load_scene("res://trailer_truck.scn") diff --git a/demos/3d/truck_town/car_select.scn b/demos/3d/truck_town/car_select.scn Binary files differindex 024adf1423..d838e995b2 100644 --- a/demos/3d/truck_town/car_select.scn +++ b/demos/3d/truck_town/car_select.scn diff --git a/demos/3d/truck_town/crane.scn b/demos/3d/truck_town/crane.scn Binary files differindex 2c4645af69..dfddd97882 100644 --- a/demos/3d/truck_town/crane.scn +++ b/demos/3d/truck_town/crane.scn diff --git a/demos/3d/truck_town/follow_camera.gd b/demos/3d/truck_town/follow_camera.gd index cf7172d7bb..7c6a0a2ba6 100644 --- a/demos/3d/truck_town/follow_camera.gd +++ b/demos/3d/truck_town/follow_camera.gd @@ -1,69 +1,57 @@ extends Camera -# member variables here, example: -# var a=2 -# var b="textvar" - -var collision_exception=[] -export var min_distance=0.5 -export var max_distance=4.0 -export var angle_v_adjust=0.0 -export var autoturn_ray_aperture=25 -export var autoturn_speed=50 +# Member variables +var collision_exception = [] +export var min_distance = 0.5 +export var max_distance = 4.0 +export var angle_v_adjust = 0.0 +export var autoturn_ray_aperture = 25 +export var autoturn_speed = 50 var max_height = 2.0 var min_height = 0 + func _fixed_process(dt): - var target = get_parent().get_global_transform().origin + var target = get_parent().get_global_transform().origin var pos = get_global_transform().origin - var up = Vector3(0,1,0) + var up = Vector3(0, 1, 0) var delta = pos - target - #regular delta follow + # Regular delta follow - #check ranges - + # Check ranges if (delta.length() < min_distance): - delta = delta.normalized() * min_distance + delta = delta.normalized()*min_distance elif (delta.length() > max_distance): - delta = delta.normalized() * max_distance + delta = delta.normalized()*max_distance - #check upper and lower height + # Check upper and lower height if ( delta.y > max_height): delta.y = max_height if ( delta.y < min_height): delta.y = min_height - + pos = target + delta - look_at_from_pos(pos,target,up) + look_at_from_pos(pos, target, up) - #turn a little up or down + # Turn a little up or down var t = get_transform() - t.basis = Matrix3(t.basis[0],deg2rad(angle_v_adjust)) * t.basis + t.basis = Matrix3(t.basis[0], deg2rad(angle_v_adjust))*t.basis set_transform(t) - - -func _ready(): -#find collision exceptions for ray +func _ready(): + # Find collision exceptions for ray var node = self while(node): if (node extends RigidBody): collision_exception.append(node.get_rid()) break else: - node=node.get_parent() - # Initalization here + node = node.get_parent() set_fixed_process(true) - #this detaches the camera transform from the parent spatial node + # This detaches the camera transform from the parent spatial node set_as_toplevel(true) - - - - - - diff --git a/demos/3d/truck_town/trailer_truck.scn b/demos/3d/truck_town/trailer_truck.scn Binary files differindex 0131e9e3a2..6fcf83e270 100644 --- a/demos/3d/truck_town/trailer_truck.scn +++ b/demos/3d/truck_town/trailer_truck.scn diff --git a/demos/3d/truck_town/truck_scene.scn b/demos/3d/truck_town/truck_scene.scn Binary files differindex a02ce259c1..0c1be13ce2 100644 --- a/demos/3d/truck_town/truck_scene.scn +++ b/demos/3d/truck_town/truck_scene.scn diff --git a/demos/3d/truck_town/trucktown.scn b/demos/3d/truck_town/trucktown.scn Binary files differindex 57a84315ee..4a8f7e7e52 100644 --- a/demos/3d/truck_town/trucktown.scn +++ b/demos/3d/truck_town/trucktown.scn diff --git a/demos/3d/truck_town/vehicle.gd b/demos/3d/truck_town/vehicle.gd index 1aa7f0faa2..c4224577c6 100644 --- a/demos/3d/truck_town/vehicle.gd +++ b/demos/3d/truck_town/vehicle.gd @@ -1,54 +1,45 @@ extends VehicleBody -# member variables here, example: -# var a=2 -# var b="textvar" +# Member variables +const STEER_SPEED = 1 +const STEER_LIMIT = 0.4 +var steer_angle = 0 +var steer_target = 0 -const STEER_SPEED=1 -const STEER_LIMIT=0.4 +export var engine_force = 40 -var steer_angle=0 -var steer_target=0 - - -export var engine_force=40 func _fixed_process(delta): - - if (Input.is_action_pressed("ui_left")): - steer_target=-STEER_LIMIT + steer_target = -STEER_LIMIT elif (Input.is_action_pressed("ui_right")): - steer_target=STEER_LIMIT + steer_target = STEER_LIMIT else: - steer_target=0 - + steer_target = 0 + if (Input.is_action_pressed("ui_up")): set_engine_force(engine_force) else: set_engine_force(0) - + if (Input.is_action_pressed("ui_down")): set_brake(1) else: set_brake(0.0) - - + if (steer_target < steer_angle): steer_angle -= STEER_SPEED*delta if (steer_target > steer_angle): - steer_angle=steer_target + steer_angle = steer_target elif (steer_target > steer_angle): steer_angle += STEER_SPEED*delta if (steer_target < steer_angle): - steer_angle=steer_target - + steer_angle = steer_target + set_steering(steer_angle) -func _ready(): - # Initalization here - set_fixed_process(true) - pass +func _ready(): + set_fixed_process(true) |