diff --git a/Level_01.tscn b/Level_01.tscn index d1afd54..1c5982b 100644 --- a/Level_01.tscn +++ b/Level_01.tscn @@ -17,7 +17,7 @@ cell_scale = 1.0 collision_layer = 1 collision_mask = 1 data = { -"cells": PoolIntArray( 0, 0, 1441792, 65534, 0, 1441792, 65535, 0, 1441792, 0, 65534, 1441792, 65534, 65534, 1441792, 65535, 65534, 1441792, 0, 65535, 1441792, 65534, 65535, 1441792 ) +"cells": PoolIntArray( 0, 0, 1612054528, 65534, 0, 1441792, 65535, 0, 1441792, 0, 65534, 1612054528, 65534, 65534, 1441792, 65535, 65534, 1441792, 0, 65535, 1441792, 65534, 65535, 1441792 ) } _sections_unfolded = [ "Cell", "Collision", "Transform", "Visibility" ] __meta__ = { diff --git a/MeshLibrary.tscn b/MeshLibrary.tscn index 5966c6b..6f85ffd 100644 --- a/MeshLibrary.tscn +++ b/MeshLibrary.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [sub_resource type="CubeMesh" id=1] @@ -59,6 +59,10 @@ proximity_fade_enable = false distance_fade_enable = false _sections_unfolded = [ "Albedo" ] +[sub_resource type="BoxShape" id=6] + +extents = Vector3( 1, 1, 1 ) + [sub_resource type="CubeMesh" id=3] size = Vector3( 2, 2, 2 ) @@ -79,7 +83,7 @@ void fragment() { render_priority = 0 shader = SubResource( 4 ) -[node name="Spatial" type="Spatial"] +[node name="Spatial" type="Spatial" index="0"] [node name="MeshSpatial" type="MeshInstance" parent="." index="0"] @@ -98,6 +102,23 @@ skeleton = NodePath("..") material/0 = SubResource( 2 ) _sections_unfolded = [ "material" ] +[node name="StaticBody" type="StaticBody" parent="MeshSpatial" index="0"] + +input_ray_pickable = true +input_capture_on_drag = false +collision_layer = 1 +collision_mask = 1 +friction = 1.0 +bounce = 0.0 +constant_linear_velocity = Vector3( 0, 0, 0 ) +constant_angular_velocity = Vector3( 0, 0, 0 ) +_sections_unfolded = [ "Collision" ] + +[node name="CollisionShape" type="CollisionShape" parent="MeshSpatial/StaticBody" index="0"] + +shape = SubResource( 6 ) +disabled = false + [node name="Camera" type="Camera" parent="." index="1"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10 ) diff --git a/Player.gd b/Player.gd index 9c7d4f7..5255edf 100644 --- a/Player.gd +++ b/Player.gd @@ -1,11 +1,14 @@ extends KinematicBody +const norm_gravity = -80 var velocity = Vector3() +const MAX_SLOPE_ANGLE = 60 func _ready(): print("player init") func _physics_process(delta): + # Keyboard input var direction = Vector3() if Input.is_action_pressed("ui_up"): @@ -20,9 +23,15 @@ func _physics_process(delta): direction.y = 0 direction = direction.normalized() - var speed = 0.2 + # Speep + var speed = 2.0 direction *= speed - self.translate(direction) + + # Gravity + direction.y = norm_gravity * delta + + # Collision + velocity = move_and_slide(direction, Vector3(0,1,0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE)) func _process(delta): # Called every frame. Delta is time since last frame. diff --git a/mlib.meshlib b/mlib.meshlib index 6b0bc8b..a4ee3e0 100644 Binary files a/mlib.meshlib and b/mlib.meshlib differ