diff --git a/2d/platformer/stage.xml b/2d/platformer/stage.xml index 6a112e02..78d0f9ae 100644 --- a/2d/platformer/stage.xml +++ b/2d/platformer/stage.xml @@ -1,19 +1,20 @@ - + - + "names" - + "stage" "Node" + "_import_path" "__meta__" "tile_map" "TileMap" @@ -28,7 +29,9 @@ "quadrant_size" "tile_set" "tile_data" - "collision_layers" + "collision/friction" + "collision/bounce" + "collision/layers" "coins" "coin" "Area2D" @@ -140,6 +143,7 @@ 66 "variants" + "" "__editor_plugin_states__" @@ -164,7 +168,7 @@ "use_snap" False "ofs" - 418.81, 615.088 + -177.089, 415.221 "snap" 10 @@ -318,7 +322,7 @@ 4236.75, 541.058 4172.75, 541.058 - 236.879, 1051.15 + 251.684, 1045.6 1451.86, 742.969 0, 140 @@ -349,16 +353,15 @@ -202 358 -10 - "" 2 - 14 + 7 14.769231 - "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. " + "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." 0 -1 "nodes" - -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 + -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 "conns" diff --git a/3d/kinematic_char/cubelib.res b/3d/kinematic_char/cubelib.res new file mode 100644 index 00000000..66b999d7 Binary files /dev/null and b/3d/kinematic_char/cubelib.res differ diff --git a/3d/kinematic_char/cubio.gd b/3d/kinematic_char/cubio.gd new file mode 100644 index 00000000..6f12e39d --- /dev/null +++ b/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/3d/kinematic_char/engine.cfg b/3d/kinematic_char/engine.cfg new file mode 100644 index 00000000..b3060b65 --- /dev/null +++ b/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/3d/kinematic_char/follow_camera.gd b/3d/kinematic_char/follow_camera.gd new file mode 100644 index 00000000..0b9ff9bb --- /dev/null +++ b/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/3d/kinematic_char/kinebody3d.png b/3d/kinematic_char/kinebody3d.png new file mode 100644 index 00000000..41f0edb2 Binary files /dev/null and b/3d/kinematic_char/kinebody3d.png differ diff --git a/3d/kinematic_char/level.scn b/3d/kinematic_char/level.scn new file mode 100644 index 00000000..785db19a Binary files /dev/null and b/3d/kinematic_char/level.scn differ diff --git a/3d/kinematic_char/purple_wood.tex b/3d/kinematic_char/purple_wood.tex new file mode 100644 index 00000000..cdf0f810 Binary files /dev/null and b/3d/kinematic_char/purple_wood.tex differ diff --git a/3d/kinematic_char/purplecube.scn b/3d/kinematic_char/purplecube.scn new file mode 100644 index 00000000..ab758366 Binary files /dev/null and b/3d/kinematic_char/purplecube.scn differ diff --git a/3d/kinematic_char/twood.tex b/3d/kinematic_char/twood.tex new file mode 100644 index 00000000..65c1bd04 Binary files /dev/null and b/3d/kinematic_char/twood.tex differ diff --git a/3d/kinematic_char/white_wood.tex b/3d/kinematic_char/white_wood.tex new file mode 100644 index 00000000..e003442e Binary files /dev/null and b/3d/kinematic_char/white_wood.tex differ