diff options
Diffstat (limited to 'demos')
19 files changed, 279 insertions, 35 deletions
diff --git a/demos/2d/kinematic_char/colworld.gd b/demos/2d/kinematic_char/colworld.gd index efd1dab805..d13ff9236b 100644 --- a/demos/2d/kinematic_char/colworld.gd +++ b/demos/2d/kinematic_char/colworld.gd @@ -1,12 +1,12 @@ extends Node2D -# member variables here, example: -# var a=2 -# var b="textvar" +#member variables here, example: +#var a=2 +#var b="textvar" func _ready(): - # Initalization here + #Initalization here pass diff --git a/demos/2d/kinematic_char/player.gd b/demos/2d/kinematic_char/player.gd index b35bbfa693..5c56477758 100644 --- a/demos/2d/kinematic_char/player.gd +++ b/demos/2d/kinematic_char/player.gd @@ -1,18 +1,18 @@ extends KinematicBody2D -# This is a simple collision demo showing how -# the kinematic cotroller works. -# move() will allow to move the node, and will -# always move it to a non-colliding spot, -# as long as it starts from a non-colliding spot too. +#This is a simple collision demo showing how +#the kinematic cotroller works. +#move() will allow to move the node, and will +#always move it to a non-colliding spot, +#as long as it starts from a non-colliding spot too. #pixels / second const GRAVITY = 500.0 -# Angle in degrees towards either side that the player can -# consider "floor". +#Angle in degrees towards either side that the player can +#consider "floor". const FLOOR_ANGLE_TOLERANCE = 40 const WALK_FORCE = 600 const WALK_MAX_SPEED = 200 @@ -68,7 +68,6 @@ func _fixed_process(delta): var motion = velocity * delta #move and consume motion -# motion = move(motion) @@ -85,9 +84,9 @@ func _fixed_process(delta): floor_velocity=get_collider_velocity() #velocity.y=0 - # But we were moving and our motion was interrupted, - # so try to complete the motion by "sliding" - # by the normal + #But we were moving and our motion was interrupted, + #so try to complete the motion by "sliding" + #by the normal motion = n.slide(motion) velocity = n.slide(velocity) @@ -109,7 +108,7 @@ func _fixed_process(delta): prev_jump_pressed=jump func _ready(): - # Initalization here + #Initalization here set_fixed_process(true) pass diff --git a/demos/2d/platformer/stage.xml b/demos/2d/platformer/stage.xml index 6a112e02aa..78d0f9ae2c 100644 --- a/demos/2d/platformer/stage.xml +++ b/demos/2d/platformer/stage.xml @@ -1,19 +1,20 @@ <?xml version="1.0" encoding="UTF-8" ?> <resource_file type="PackedScene" subresource_count="9" version="1.0" version_name="Godot Engine v1.0.3917-beta1"> - <ext_resource path="res://music.ogg" type="AudioStream"></ext_resource> <ext_resource path="res://tileset.xml" type="TileSet"></ext_resource> + <ext_resource path="res://music.ogg" type="AudioStream"></ext_resource> <ext_resource path="res://coin.xml" type="PackedScene"></ext_resource> <ext_resource path="res://player.xml" type="PackedScene"></ext_resource> - <ext_resource path="res://moving_platform.xml" type="PackedScene"></ext_resource> <ext_resource path="res://seesaw.xml" type="PackedScene"></ext_resource> + <ext_resource path="res://moving_platform.xml" type="PackedScene"></ext_resource> <ext_resource path="res://enemy.xml" type="PackedScene"></ext_resource> <ext_resource path="res://parallax_bg.xml" type="PackedScene"></ext_resource> <main_resource> <dictionary name="_bundled" shared="false"> <string> "names" </string> - <string_array len="119"> + <string_array len="122"> <string> "stage" </string> <string> "Node" </string> + <string> "_import_path" </string> <string> "__meta__" </string> <string> "tile_map" </string> <string> "TileMap" </string> @@ -28,7 +29,9 @@ <string> "quadrant_size" </string> <string> "tile_set" </string> <string> "tile_data" </string> - <string> "collision_layers" </string> + <string> "collision/friction" </string> + <string> "collision/bounce" </string> + <string> "collision/layers" </string> <string> "coins" </string> <string> "coin" </string> <string> "Area2D" </string> @@ -140,6 +143,7 @@ <int> 66 </int> <string> "variants" </string> <array len="96" shared="false"> + <node_path> "" </node_path> <dictionary shared="false"> <string> "__editor_plugin_states__" </string> <dictionary shared="false"> @@ -164,7 +168,7 @@ <string> "use_snap" </string> <bool> False </bool> <string> "ofs" </string> - <vector2> 418.81, 615.088 </vector2> + <vector2> -177.089, 415.221 </vector2> <string> "snap" </string> <int> 10 </int> </dictionary> @@ -318,7 +322,7 @@ <vector2> 4236.75, 541.058 </vector2> <vector2> 4172.75, 541.058 </vector2> <resource resource_type="PackedScene" path="res://player.xml"> </resource> - <vector2> 236.879, 1051.15 </vector2> + <vector2> 251.684, 1045.6 </vector2> <resource resource_type="PackedScene" path="res://moving_platform.xml"> </resource> <vector2> 1451.86, 742.969 </vector2> <vector2> 0, 140 </vector2> @@ -349,16 +353,15 @@ <real> -202 </real> <real> 358 </real> <real> -10 </real> - <node_path> "" </node_path> <int> 2 </int> - <real> 14 </real> + <real> 7 </real> <real> 14.769231 </real> - <string> "This is a simple demo on how to make a platformer game with Godot. This version uses physics and the 2D physics engine for motion and collision. The demo also shows the benefits of using the scene system, where coins, enemies and the player are edited separatedly and instanced in the stage. To edit the base tiles for the tileset, open the tileset_edit.xml file and follow instructions. " </string> + <string> "This is a simple demo on how to make a platformer game with Godot.This version uses physics and the 2D physics engine for motion and collision.The demo also shows the benefits of using the scene system, where coins,enemies and the player are edited separatedly and instanced in the stage.To edit the base tiles for the tileset, open the tileset_edit.xml file and follow instructions." </string> <int> 0 </int> <real> -1 </real> </array> <string> "nodes" </string> - <int_array len="690"> -1, -1, 1, 0, -1, 1, 2, 0, 0, 0, 0, 4, 3, -1, 13, 5, 1, 6, 2, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12, 7, 13, 8, 14, 9, 15, 10, 16, 11, 2, 12, 0, 0, 0, 1, 17, -1, 1, 2, 13, 0, 2, 0, 19, 18, 14, 1, 9, 15, 0, 2, 0, 19, 20, 14, 1, 9, 16, 0, 2, 0, 19, 21, 14, 1, 9, 17, 0, 2, 0, 19, 22, 14, 1, 9, 18, 0, 2, 0, 19, 23, 14, 1, 9, 19, 0, 2, 0, 19, 24, 14, 1, 9, 20, 0, 2, 0, 19, 25, 14, 1, 9, 21, 0, 2, 0, 19, 26, 14, 1, 9, 22, 0, 2, 0, 19, 27, 14, 1, 9, 23, 0, 2, 0, 19, 28, 14, 1, 9, 24, 0, 2, 0, 19, 29, 14, 1, 9, 25, 0, 2, 0, 19, 30, 14, 1, 9, 26, 0, 2, 0, 19, 31, 14, 1, 9, 27, 0, 2, 0, 19, 32, 14, 1, 9, 28, 0, 2, 0, 19, 33, 14, 1, 9, 29, 0, 2, 0, 19, 34, 14, 1, 9, 30, 0, 2, 0, 19, 35, 14, 1, 9, 31, 0, 2, 0, 19, 36, 14, 1, 9, 32, 0, 2, 0, 19, 37, 14, 1, 9, 33, 0, 2, 0, 19, 38, 14, 1, 9, 34, 0, 2, 0, 19, 39, 14, 1, 9, 35, 0, 2, 0, 19, 40, 14, 1, 9, 36, 0, 2, 0, 19, 41, 14, 1, 9, 37, 0, 2, 0, 19, 42, 14, 1, 9, 38, 0, 2, 0, 19, 43, 14, 1, 9, 39, 0, 2, 0, 19, 44, 14, 1, 9, 40, 0, 2, 0, 19, 45, 14, 1, 9, 41, 0, 2, 0, 19, 46, 14, 1, 9, 42, 0, 2, 0, 19, 47, 14, 1, 9, 43, 0, 2, 0, 19, 48, 14, 1, 9, 44, 0, 2, 0, 19, 49, 14, 1, 9, 45, 0, 2, 0, 19, 50, 14, 1, 9, 46, 0, 2, 0, 19, 51, 14, 1, 9, 47, 0, 2, 0, 19, 52, 14, 1, 9, 48, 0, 2, 0, 19, 53, 14, 1, 9, 49, 0, 2, 0, 19, 54, 14, 1, 9, 50, 0, 2, 0, 19, 55, 14, 1, 9, 51, 0, 2, 0, 19, 56, 14, 1, 9, 52, 0, 2, 0, 19, 57, 14, 1, 9, 53, 0, 2, 0, 19, 58, 14, 1, 9, 54, 0, 2, 0, 19, 59, 14, 1, 9, 55, 0, 2, 0, 19, 60, 14, 1, 9, 56, 0, 0, 0, 62, 61, 57, 1, 9, 58, 0, 0, 0, 1, 63, -1, 0, 0, 46, 0, 65, 64, 59, 3, 9, 60, 66, 61, 67, 62, 0, 46, 0, 65, 68, 59, 3, 9, 63, 66, 64, 67, 65, 0, 46, 0, 65, 69, 59, 3, 9, 66, 66, 67, 67, 65, 0, 46, 0, 65, 70, 68, 1, 9, 69, 0, 0, 0, 72, 71, -1, 6, 73, 70, 74, 3, 75, 1, 76, 71, 77, 1, 78, 3, 0, 0, 0, 1, 79, -1, 0, 0, 52, 0, 62, 80, 72, 1, 9, 73, 0, 52, 0, 62, 81, 72, 1, 9, 74, 0, 52, 0, 62, 82, 72, 1, 9, 75, 0, 52, 0, 62, 83, 72, 1, 9, 76, 0, 52, 0, 62, 84, 72, 1, 9, 77, 0, 52, 0, 62, 85, 72, 1, 9, 78, 0, 52, 0, 62, 86, 72, 1, 9, 79, 0, 52, 0, 62, 87, 72, 1, 9, 80, 0, 52, 0, 62, 88, 72, 1, 9, 81, 0, 52, 0, 62, 89, 72, 1, 9, 82, 0, 52, 0, 62, 90, 72, 1, 9, 83, 0, 0, 0, 92, 91, 84, 0, 0, 0, 0, 93, 93, -1, 29, 5, 1, 6, 2, 7, 2, 8, 3, 94, 85, 95, 86, 96, 87, 97, 88, 98, 89, 99, 89, 100, 89, 101, 89, 102, 1, 103, 1, 104, 90, 105, 2, 106, 5, 107, 91, 108, 2, 109, 92, 110, 5, 111, 3, 112, 3, 113, 93, 114, 94, 115, 94, 116, 1, 117, 3, 118, 95, 0 </int_array> + <int_array len="708"> -1, -1, 1, 0, -1, 2, 2, 0, 3, 1, 0, 0, 0, 5, 4, -1, 16, 2, 0, 6, 2, 7, 3, 8, 3, 9, 4, 10, 5, 11, 6, 12, 7, 13, 8, 14, 9, 15, 10, 16, 11, 17, 3, 18, 6, 19, 12, 3, 13, 0, 0, 0, 1, 20, -1, 2, 2, 0, 3, 14, 0, 2, 0, 22, 21, 15, 1, 10, 16, 0, 2, 0, 22, 23, 15, 1, 10, 17, 0, 2, 0, 22, 24, 15, 1, 10, 18, 0, 2, 0, 22, 25, 15, 1, 10, 19, 0, 2, 0, 22, 26, 15, 1, 10, 20, 0, 2, 0, 22, 27, 15, 1, 10, 21, 0, 2, 0, 22, 28, 15, 1, 10, 22, 0, 2, 0, 22, 29, 15, 1, 10, 23, 0, 2, 0, 22, 30, 15, 1, 10, 24, 0, 2, 0, 22, 31, 15, 1, 10, 25, 0, 2, 0, 22, 32, 15, 1, 10, 26, 0, 2, 0, 22, 33, 15, 1, 10, 27, 0, 2, 0, 22, 34, 15, 1, 10, 28, 0, 2, 0, 22, 35, 15, 1, 10, 29, 0, 2, 0, 22, 36, 15, 1, 10, 30, 0, 2, 0, 22, 37, 15, 1, 10, 31, 0, 2, 0, 22, 38, 15, 1, 10, 32, 0, 2, 0, 22, 39, 15, 1, 10, 33, 0, 2, 0, 22, 40, 15, 1, 10, 34, 0, 2, 0, 22, 41, 15, 1, 10, 35, 0, 2, 0, 22, 42, 15, 1, 10, 36, 0, 2, 0, 22, 43, 15, 1, 10, 37, 0, 2, 0, 22, 44, 15, 1, 10, 38, 0, 2, 0, 22, 45, 15, 1, 10, 39, 0, 2, 0, 22, 46, 15, 1, 10, 40, 0, 2, 0, 22, 47, 15, 1, 10, 41, 0, 2, 0, 22, 48, 15, 1, 10, 42, 0, 2, 0, 22, 49, 15, 1, 10, 43, 0, 2, 0, 22, 50, 15, 1, 10, 44, 0, 2, 0, 22, 51, 15, 1, 10, 45, 0, 2, 0, 22, 52, 15, 1, 10, 46, 0, 2, 0, 22, 53, 15, 1, 10, 47, 0, 2, 0, 22, 54, 15, 1, 10, 48, 0, 2, 0, 22, 55, 15, 1, 10, 49, 0, 2, 0, 22, 56, 15, 1, 10, 50, 0, 2, 0, 22, 57, 15, 1, 10, 51, 0, 2, 0, 22, 58, 15, 1, 10, 52, 0, 2, 0, 22, 59, 15, 1, 10, 53, 0, 2, 0, 22, 60, 15, 1, 10, 54, 0, 2, 0, 22, 61, 15, 1, 10, 55, 0, 2, 0, 22, 62, 15, 1, 10, 56, 0, 2, 0, 22, 63, 15, 1, 10, 57, 0, 0, 0, 65, 64, 58, 1, 10, 59, 0, 0, 0, 1, 66, -1, 1, 2, 0, 0, 46, 0, 68, 67, 60, 3, 10, 61, 69, 62, 70, 63, 0, 46, 0, 68, 71, 60, 3, 10, 64, 69, 65, 70, 66, 0, 46, 0, 68, 72, 60, 3, 10, 67, 69, 68, 70, 66, 0, 46, 0, 68, 73, 69, 1, 10, 70, 0, 0, 0, 75, 74, -1, 7, 2, 0, 76, 71, 77, 4, 78, 2, 79, 72, 80, 2, 81, 4, 0, 0, 0, 1, 82, -1, 1, 2, 0, 0, 52, 0, 65, 83, 73, 1, 10, 74, 0, 52, 0, 65, 84, 73, 1, 10, 75, 0, 52, 0, 65, 85, 73, 1, 10, 76, 0, 52, 0, 65, 86, 73, 1, 10, 77, 0, 52, 0, 65, 87, 73, 1, 10, 78, 0, 52, 0, 65, 88, 73, 1, 10, 79, 0, 52, 0, 65, 89, 73, 1, 10, 80, 0, 52, 0, 65, 90, 73, 1, 10, 81, 0, 52, 0, 65, 91, 73, 1, 10, 82, 0, 52, 0, 65, 92, 73, 1, 10, 83, 0, 52, 0, 65, 93, 73, 1, 10, 84, 0, 0, 0, 95, 94, 85, 0, 0, 0, 0, 96, 96, -1, 30, 2, 0, 6, 2, 7, 3, 8, 3, 9, 4, 97, 86, 98, 87, 99, 88, 100, 89, 101, 0, 102, 0, 103, 0, 104, 0, 105, 2, 106, 2, 107, 90, 108, 3, 109, 6, 110, 91, 111, 3, 112, 92, 113, 6, 114, 4, 115, 4, 116, 93, 117, 94, 118, 94, 119, 2, 120, 4, 121, 95, 0 </int_array> <string> "conns" </string> <int_array len="0"> </int_array> </dictionary> diff --git a/demos/2d/pong/pong.gd b/demos/2d/pong/pong.gd index bfffdcf0d8..cf6003c659 100644 --- a/demos/2d/pong/pong.gd +++ b/demos/2d/pong/pong.gd @@ -1,9 +1,9 @@ extends Node2D -# member variables here, example: -# var a=2 -# var b="textvar" +#member variables here, example: +#var a=2 +#var b="textvar" const INITIAL_BALL_SPEED = 80 var ball_speed = INITIAL_BALL_SPEED var screen_size = Vector2(640,400) @@ -16,7 +16,7 @@ const PAD_SPEED = 150 func _process(delta): - # get ball positio and pad rectangles + #get ball position and pad rectangles var ball_pos = get_node("ball").get_pos() var left_rect = Rect2( get_node("left").get_pos() - pad_size*0.5, pad_size ) var right_rect = Rect2( get_node("right").get_pos() - pad_size*0.5, pad_size ) @@ -44,7 +44,7 @@ func _process(delta): get_node("ball").set_pos(ball_pos) - #move left pad + #move left pad var left_pos = get_node("left").get_pos() if (left_pos.y > 0 and Input.is_action_pressed("left_move_up")): @@ -67,7 +67,7 @@ func _process(delta): func _ready(): - screen_size = get_viewport_rect().size # get actual size + screen_size = get_viewport_rect().size #get actual size pad_size = get_node("left").get_texture().get_size() set_process(true) diff --git a/demos/3d/kinematic_char/cubelib.res b/demos/3d/kinematic_char/cubelib.res Binary files differnew file mode 100644 index 0000000000..66b999d78d --- /dev/null +++ b/demos/3d/kinematic_char/cubelib.res diff --git a/demos/3d/kinematic_char/cubio.gd b/demos/3d/kinematic_char/cubio.gd new file mode 100644 index 0000000000..6f12e39db7 --- /dev/null +++ b/demos/3d/kinematic_char/cubio.gd @@ -0,0 +1,96 @@ + +extends KinematicBody + +# member variables here, example: +# var a=2 +# var b="textvar" + +var g = -9.8 +var vel = Vector3() +const MAX_SPEED = 5 +const JUMP_SPEED = 7 +const ACCEL= 2 +const DEACCEL= 4 +const MAX_SLOPE_ANGLE = 30 + +func _fixed_process(delta): + + var dir = Vector3() #where does the player intend to walk to + var cam_xform = get_node("target/camera").get_global_transform() + + if (Input.is_action_pressed("move_forward")): + dir+=-cam_xform.basis[2] + if (Input.is_action_pressed("move_backwards")): + dir+=cam_xform.basis[2] + if (Input.is_action_pressed("move_left")): + dir+=-cam_xform.basis[0] + if (Input.is_action_pressed("move_right")): + dir+=cam_xform.basis[0] + + dir.y=0 + dir=dir.normalized() + + vel.y+=delta*g + + var hvel = vel + hvel.y=0 + + var target = dir*MAX_SPEED + var accel + if (dir.dot(hvel) >0): + accel=ACCEL + else: + accel=DEACCEL + + hvel = hvel.linear_interpolate(target,accel*delta) + + vel.x=hvel.x; + vel.z=hvel.z + + var motion = vel*delta + motion=move(vel*delta) + + var on_floor = false + var original_vel = vel + + + var floor_velocity=Vector2() + + var attempts=4 + + while(is_colliding() and attempts): + var n=get_collision_normal() + + if ( rad2deg(acos(n.dot( Vector3(0,1,0)))) < MAX_SLOPE_ANGLE ): + #if angle to the "up" vectors is < angle tolerance + #char is on floor + floor_velocity=get_collider_velocity() + on_floor=true + + motion = n.slide(motion) + vel = n.slide(vel) + if (original_vel.dot(vel) > 0): + #do not allow to slide towads the opposite direction we were coming from + motion=move(motion) + if (motion.length()<0.001): + break + attempts-=1 + + if (on_floor and floor_velocity!=Vector3()): + move(floor_velocity*delta) + + if (on_floor and Input.is_action_pressed("jump")): + vel.y=JUMP_SPEED + + var crid = get_node("../elevator1").get_rid() +# print(crid," : ",PS.body_get_state(crid,PS.BODY_STATE_TRANSFORM)) + +func _ready(): + # Initalization here + set_fixed_process(true) + pass + + +func _on_tcube_body_enter( body ): + get_node("../ty").show() + pass # replace with function body diff --git a/demos/3d/kinematic_char/engine.cfg b/demos/3d/kinematic_char/engine.cfg new file mode 100644 index 0000000000..b3060b65e0 --- /dev/null +++ b/demos/3d/kinematic_char/engine.cfg @@ -0,0 +1,17 @@ +[application] + +name="Kinematic Character 3D" +main_scene="res://level.scn" +icon="res://kinebody3d.png" + +[input] + +move_forward=[key(Up)] +move_left=[key(Left)] +move_right=[key(Right)] +move_backwards=[key(Down)] +jump=[key(Space)] + +[rasterizer] + +shadow_filter=3 diff --git a/demos/3d/kinematic_char/follow_camera.gd b/demos/3d/kinematic_char/follow_camera.gd new file mode 100644 index 0000000000..0b9ff9bbb2 --- /dev/null +++ b/demos/3d/kinematic_char/follow_camera.gd @@ -0,0 +1,92 @@ + +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 +var max_height = 2.0 +var min_height = 0 + +func _fixed_process(dt): + var target = get_parent().get_global_transform().origin + var pos = get_global_transform().origin + var up = Vector3(0,1,0) + + var delta = pos - target + + #regular delta follow + + #check ranges + + if (delta.length() < min_distance): + delta = delta.normalized() * min_distance + elif (delta.length() > max_distance): + delta = delta.normalized() * max_distance + + #check upper and lower height + if ( delta.y > max_height): + delta.y = max_height + if ( delta.y < min_height): + delta.y = min_height + + #check autoturn + + var ds = PhysicsServer.space_get_direct_state( get_world().get_space() ) + + + var col_left = ds.intersect_ray(target,target+Matrix3(up,deg2rad(autoturn_ray_aperture)).xform(delta),collision_exception) + var col = ds.intersect_ray(target,target,collision_exception) + var col_right = ds.intersect_ray(target,target+Matrix3(up,deg2rad(-autoturn_ray_aperture)).xform(delta),collision_exception) + + if (col!=null): + #if main ray was occluded, get camera closer, this is the worst case scenario + delta = col.position - target + elif (col_left!=null and col_right==null): + #if only left ray is occluded, turn the camera around to the right + delta = Matrix3(up,deg2rad(-dt*autoturn_speed)).xform(delta) + elif (col_left==null and col_right!=null): + #if only right ray is occluded, turn the camera around to the left + delta = Matrix3(up,deg2rad(dt*autoturn_speed)).xform(delta) + else: + #do nothing otherwise, left and right are occluded but center is not, so do not autoturn + pass + + #apply lookat + pos = target + delta + + look_at_from_pos(pos,target,up) + + #turn a little up or down + var t = get_transform() + t.basis = Matrix3(t.basis[0],deg2rad(angle_v_adjust)) * t.basis + set_transform(t) + + + +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 + set_fixed_process(true) + #this detaches the camera transform from the parent spatial node + set_as_toplevel(true) + + + + + + diff --git a/demos/3d/kinematic_char/kinebody3d.png b/demos/3d/kinematic_char/kinebody3d.png Binary files differnew file mode 100644 index 0000000000..41f0edb246 --- /dev/null +++ b/demos/3d/kinematic_char/kinebody3d.png diff --git a/demos/3d/kinematic_char/level.scn b/demos/3d/kinematic_char/level.scn Binary files differnew file mode 100644 index 0000000000..1d7e5a4a70 --- /dev/null +++ b/demos/3d/kinematic_char/level.scn diff --git a/demos/3d/kinematic_char/purple_wood.tex b/demos/3d/kinematic_char/purple_wood.tex Binary files differnew file mode 100644 index 0000000000..cdf0f810f1 --- /dev/null +++ b/demos/3d/kinematic_char/purple_wood.tex diff --git a/demos/3d/kinematic_char/purplecube.scn b/demos/3d/kinematic_char/purplecube.scn Binary files differnew file mode 100644 index 0000000000..ab758366fd --- /dev/null +++ b/demos/3d/kinematic_char/purplecube.scn diff --git a/demos/3d/kinematic_char/twood.tex b/demos/3d/kinematic_char/twood.tex Binary files differnew file mode 100644 index 0000000000..65c1bd043c --- /dev/null +++ b/demos/3d/kinematic_char/twood.tex diff --git a/demos/3d/kinematic_char/white_wood.tex b/demos/3d/kinematic_char/white_wood.tex Binary files differnew file mode 100644 index 0000000000..e003442e70 --- /dev/null +++ b/demos/3d/kinematic_char/white_wood.tex diff --git a/demos/3d/mousepick_test/engine.cfg b/demos/3d/mousepick_test/engine.cfg new file mode 100644 index 0000000000..093999a87a --- /dev/null +++ b/demos/3d/mousepick_test/engine.cfg @@ -0,0 +1,5 @@ +[application] + +name="3D Mouse Picking Test" +main_scene="res://mousepick.scn" +icon="res://icon.png" diff --git a/demos/3d/mousepick_test/icon.png b/demos/3d/mousepick_test/icon.png Binary files differnew file mode 100644 index 0000000000..264f991e15 --- /dev/null +++ b/demos/3d/mousepick_test/icon.png diff --git a/demos/3d/mousepick_test/mousepick.gd b/demos/3d/mousepick_test/mousepick.gd new file mode 100644 index 0000000000..cf3d9f1e4e --- /dev/null +++ b/demos/3d/mousepick_test/mousepick.gd @@ -0,0 +1,32 @@ + +extends RigidBody + +# member variables here, example: +# var a=2 +# var b="textvar" + +var gray_mat = FixedMaterial.new() + +var selected=false + +func _input_event(event,pos,normal,shape): + if (event.type==InputEvent.MOUSE_BUTTON and event.pressed): + if (not selected): + get_node("mesh").set_material_override(gray_mat) + else: + get_node("mesh").set_material_override(null) + + selected = not selected + + +func _mouse_enter(): + get_node("mesh").set_scale( Vector3(1.1,1.1,1.1) ) + +func _mouse_exit(): + get_node("mesh").set_scale( Vector3(1,1,1) ) + +func _ready(): + # Initalization here + pass + + diff --git a/demos/3d/mousepick_test/mousepick.scn b/demos/3d/mousepick_test/mousepick.scn Binary files differnew file mode 100644 index 0000000000..7ecac46a86 --- /dev/null +++ b/demos/3d/mousepick_test/mousepick.scn diff --git a/demos/3d/platformer/follow_camera.gd b/demos/3d/platformer/follow_camera.gd index 0b9ff9bbb2..60eef5787a 100644 --- a/demos/3d/platformer/follow_camera.gd +++ b/demos/3d/platformer/follow_camera.gd @@ -45,13 +45,13 @@ func _fixed_process(dt): var col = ds.intersect_ray(target,target,collision_exception) var col_right = ds.intersect_ray(target,target+Matrix3(up,deg2rad(-autoturn_ray_aperture)).xform(delta),collision_exception) - if (col!=null): + if (!col.empty()): #if main ray was occluded, get camera closer, this is the worst case scenario delta = col.position - target - elif (col_left!=null and col_right==null): + elif (!col_left.empty() and col_right.empty()): #if only left ray is occluded, turn the camera around to the right delta = Matrix3(up,deg2rad(-dt*autoturn_speed)).xform(delta) - elif (col_left==null and col_right!=null): + elif (col_left.empty() and !col_right.empty()): #if only right ray is occluded, turn the camera around to the left delta = Matrix3(up,deg2rad(dt*autoturn_speed)).xform(delta) else: |