From 50af5e0b16abd19bfc9a6ca11187278f66fcd5f3 Mon Sep 17 00:00:00 2001 From: AiTechEye <40591179+AiTechEye@users.noreply.github.com> Date: Fri, 18 Oct 2019 20:52:15 +0200 Subject: [PATCH] Add files via upload --- KinematicBody.gd | 82 ++++++++++++++++++++++++ default.png | Bin 0 -> 395 bytes default_env.tres | 7 +++ ground.tscn | 22 +++++++ icon.png | Bin 0 -> 1409 bytes main.tscn | 161 +++++++++++++++++++++++++++++++++++++++++++++++ project.godot | 42 +++++++++++++ 7 files changed, 314 insertions(+) create mode 100644 KinematicBody.gd create mode 100644 default.png create mode 100644 default_env.tres create mode 100644 ground.tscn create mode 100644 icon.png create mode 100644 main.tscn create mode 100644 project.godot diff --git a/KinematicBody.gd b/KinematicBody.gd new file mode 100644 index 0000000..5a07876 --- /dev/null +++ b/KinematicBody.gd @@ -0,0 +1,82 @@ +extends KinematicBody + +var direction = Vector3() +var velocity = Vector3() + +var gravity = -27 +var jump_height = 10 +var walk_speed = 10 + +var fpv_camera_angle = 0 +var fpv_mouse_sensitivity = 0.3 +# == phys +var phys_area_object +onready var phys_area = $head/Area +onready var phys_area_aim = $head/Area/aim + + +func _ready(): + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + $player_mesh.visible = false + OS.set_window_position(Vector2(0,0)) + +# == control +func _input(event): + if Input.is_action_just_pressed("ui_cancel"): + get_tree().quit() + if event is InputEventMouseMotion: + rotate_y(deg2rad(-event.relative.x * fpv_mouse_sensitivity)) + var change = -event.relative.y * fpv_mouse_sensitivity + if change + fpv_camera_angle < 90 and change + fpv_camera_angle > -90: + $head.rotate_x(deg2rad(change)) + fpv_camera_angle += change + +# == phys + + if Input.is_action_just_pressed("left_click"): + for body in phys_area.get_overlapping_bodies(): + if body is RigidBody: + phys_area_object = body + return + if Input.is_action_just_released("left_click"): + phys_area_object = null + if Input.is_action_just_pressed("right_click") and phys_area_object != null and weakref(phys_area_object).get_ref(): + var a = phys_area_aim.get_global_transform().origin + var b = phys_area_object.get_global_transform().origin + + phys_area_object.set_linear_velocity((b-a)*10) + phys_area_object = null + +# == phys + +func _physics_process(delta): + if phys_area_object != null and weakref(phys_area_object).get_ref(): + var a = phys_area.get_global_transform().origin + var b = phys_area_object.get_global_transform().origin + phys_area_object.set_linear_velocity((a-b)*10) + if phys_area_object.get("timer") != null: + phys_area_object.timer = 0 + +# == move + +func _process(delta): + direction = Vector3() + var aim = $head/Camera.get_global_transform().basis + if Input.is_key_pressed(KEY_W): + direction -= aim.z + if Input.is_key_pressed(KEY_S): + direction += aim.z + if Input.is_key_pressed(KEY_A): + direction -= aim.x + if Input.is_key_pressed(KEY_D): + direction += aim.x + direction = direction.normalized() + velocity.y += gravity * delta + var tv = velocity + tv = velocity.linear_interpolate(direction * walk_speed,6 * delta) + velocity.x = tv.x + velocity.z = tv.z + velocity = move_and_slide(velocity,Vector3(0,1,0)) +# == jumping + if is_on_floor() and Input.is_key_pressed(KEY_SPACE): + velocity.y = jump_height \ No newline at end of file diff --git a/default.png b/default.png new file mode 100644 index 0000000000000000000000000000000000000000..078a0fc268684bc0dbdd4cb54f8647fecb5b00d0 GIT binary patch literal 395 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1SEZ8zRdwroCO|{#S9F3${@^GvDCf{D9B#o z>Fdh=m{X8PMQV>?!G55SWQl7;iF1B#Zfaf$gL6@8Vo7R>LV0FMhJw4NZ$Nk>pEv^p zBde#2V@SoVw|6)4IxF(H2C5q{^8PMg<93+MBXg4Er}-uCSf=$&u>KsC9a{8!&WoSb zp=T|fm*1}r56#vs`B(jZ_m}HHs}vX*SU?UHU|?WkaA08I0Gdpu;DFdh=m`g}Vk57K5I1f-rvcxr_#5q4VH#M(>!MP|ku_QG`p**uBL&4qCHz2%`Pn>~) z<+rDcV@SoVw|8#_-LVj9NYvf7=Zo9Da=p(77Z!39rXr*VD(##1ancV;0_c<`~ z*7wDHY6|lbDadYGPupds|lJef8w%UgeeFy|f@c)bi=R zdgE0QFJ|qSemd>nhPCAZQ-j~F=%2c7&8FM?Svb3+np&P$f^5CJf0gdaxbJ?uy~3yd z+qF|dRc}+p$GAVA_mtfa+dBKe)9tsles%3%yK1s!=`QOVhp%1xw$62$rtj7(X1Cwk z-{;m=7Jl9PEbL!EkWu9fced%dOh$*OBpE^{A`ZYlk| ztt{$l_Oa0AyYGE*FWwU}eY17^ou_ZkowLe*GilnsSNmJ^SN#| z)7ZI%X@2Ek@`$7tEIuBbFXan4~mJqec_fL>$=lY#W_KbdxE_>Pt18f z;qZ*(mgk-2xTL~mlJDLx`=$SMN@<_a+_J4Jw{KWeNL?mR#b#erC#pbK&N9{_s8f-Tsw*_B6kpZszyp8#TXP z_D;13?})c~@~fJ8tL@2-4P2S4w>(cST=zl$QDzopr E0NeCrF8}}l literal 0 HcmV?d00001 diff --git a/main.tscn b/main.tscn new file mode 100644 index 0000000..1866895 --- /dev/null +++ b/main.tscn @@ -0,0 +1,161 @@ +[gd_scene load_steps=16 format=2] + +[ext_resource path="res://default.png" type="Texture" id=1] +[ext_resource path="res://KinematicBody.gd" type="Script" id=2] + +[sub_resource type="SpatialMaterial" id=1] +albedo_texture = ExtResource( 1 ) +uv1_scale = Vector3( 10, 1, 10 ) +uv1_triplanar = true + +[sub_resource type="CubeMesh" id=2] + +[sub_resource type="BoxShape" id=3] + +[sub_resource type="CubeMesh" id=4] + +[sub_resource type="SpatialMaterial" id=5] +albedo_color = Color( 1, 0, 0, 1 ) + +[sub_resource type="CapsuleShape" id=6] + +[sub_resource type="BoxShape" id=7] + +[sub_resource type="SphereShape" id=8] + +[sub_resource type="SphereMesh" id=9] + +[sub_resource type="SpatialMaterial" id=10] +albedo_color = Color( 0, 0.670588, 0.0117647, 1 ) + +[sub_resource type="BoxShape" id=11] + +[sub_resource type="CubeMesh" id=12] + +[sub_resource type="SpatialMaterial" id=13] +albedo_color = Color( 0, 0.0392157, 1, 1 ) + +[node name="Spatial" type="Spatial"] + +[node name="Ground" type="MeshInstance" parent="."] +editor/display_folded = true +transform = Transform( 20.282, 0, 0, 0, 3.00821, 0, 0, 0, 19.2005, 0, -3.90285, -3.40485 ) +material_override = SubResource( 1 ) +mesh = SubResource( 2 ) +material/0 = null + +[node name="StaticBody" type="StaticBody" parent="Ground"] + +[node name="CollisionShape" type="CollisionShape" parent="Ground/StaticBody"] +shape = SubResource( 3 ) + +[node name="box1" type="MeshInstance" parent="."] +editor/display_folded = true +transform = Transform( 6.12884, 0, 0, 0, 3.00821, 0, 0, 0, 6.826, -8.45122, -1.0583, -13.336 ) +material_override = SubResource( 1 ) +mesh = SubResource( 2 ) +material/0 = null + +[node name="StaticBody" type="StaticBody" parent="box1"] + +[node name="CollisionShape" type="CollisionShape" parent="box1/StaticBody"] +shape = SubResource( 3 ) + +[node name="box2" type="MeshInstance" parent="."] +editor/display_folded = true +transform = Transform( 3.72134, 0, 0, 0, 1.8561, 0, 0, 0, 2.94374, 3.52478, -1.08219, -12.5602 ) +material_override = SubResource( 1 ) +mesh = SubResource( 2 ) +material/0 = null + +[node name="StaticBody" type="StaticBody" parent="box2"] + +[node name="CollisionShape" type="CollisionShape" parent="box2/StaticBody"] +shape = SubResource( 3 ) + +[node name="player" type="Spatial" parent="."] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -8.65268, 0 ) + +[node name="KinematicBody" type="KinematicBody" parent="player"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8.07249, 1.84711 ) +script = ExtResource( 2 ) + +[node name="player_mesh" type="MeshInstance" parent="player/KinematicBody"] +transform = Transform( 0.404405, 0, 0, 0, 0.893384, 0, 0, 0, 0.372423, 0, 1.54014, 0 ) +mesh = SubResource( 4 ) +material/0 = SubResource( 5 ) + +[node name="CollisionShape" type="CollisionShape" parent="player/KinematicBody"] +transform = Transform( 0.636057, 0, 0, 0, -4.37114e-008, -1, 0, 0.605457, -2.64654e-008, 0, 1.54517, 0 ) +shape = SubResource( 6 ) + +[node name="head" type="Spatial" parent="player/KinematicBody"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.66905, 0 ) + +[node name="Camera" type="Camera" parent="player/KinematicBody/head"] + +[node name="Area" type="Area" parent="player/KinematicBody/head"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.241424, -2 ) + +[node name="CollisionShape" type="CollisionShape" parent="player/KinematicBody/head/Area"] +shape = SubResource( 7 ) + +[node name="aim" type="Spatial" parent="player/KinematicBody/head/Area"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3 ) + +[node name="ball" type="RigidBody" parent="."] +editor/display_folded = true +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -4.02767, 0, -2.0248 ) + +[node name="CollisionShape" type="CollisionShape" parent="ball"] +shape = SubResource( 8 ) + +[node name="MeshInstance" type="MeshInstance" parent="ball"] +mesh = SubResource( 9 ) +material/0 = SubResource( 10 ) + +[node name="ball2" type="RigidBody" parent="."] +editor/display_folded = true +transform = Transform( 0.63416, 0, 0, 0, 0.63416, 0, 0, 0, 0.63416, -0.7296, 0, -2.0248 ) + +[node name="CollisionShape" type="CollisionShape" parent="ball2"] +shape = SubResource( 8 ) + +[node name="MeshInstance" type="MeshInstance" parent="ball2"] +mesh = SubResource( 9 ) +material/0 = SubResource( 10 ) + +[node name="cube" type="RigidBody" parent="."] +editor/display_folded = true +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5.75055, 1, -0.45817 ) + +[node name="CollisionShape" type="CollisionShape" parent="cube"] +shape = SubResource( 11 ) + +[node name="MeshInstance" type="MeshInstance" parent="cube"] +mesh = SubResource( 12 ) +material/0 = SubResource( 13 ) + +[node name="cube2" type="RigidBody" parent="."] +editor/display_folded = true +transform = Transform( 0.408973, 0, 0, 0, 0.408973, 0, 0, 0, 0.408973, 2.49498, 1, -3.60651 ) + +[node name="CollisionShape" type="CollisionShape" parent="cube2"] +shape = SubResource( 11 ) + +[node name="MeshInstance" type="MeshInstance" parent="cube2"] +mesh = SubResource( 12 ) +material/0 = SubResource( 13 ) + +[node name="cube3" type="RigidBody" parent="."] +editor/display_folded = true +transform = Transform( 0.408973, 0, 0, 0, 0.408973, 0, 0, 0, 0.408973, -2.15019, 2.52685, -7.3701 ) + +[node name="CollisionShape" type="CollisionShape" parent="cube3"] +transform = Transform( 4.82578, 0, 0, 0, 0.393227, 0, 0, 0, 0.512657, 0, 0, 0 ) +shape = SubResource( 11 ) + +[node name="MeshInstance" type="MeshInstance" parent="cube3"] +transform = Transform( 4.82578, 0, 0, 0, 0.393227, 0, 0, 0, 0.512657, 0, 0, 0 ) +mesh = SubResource( 12 ) +material/0 = SubResource( 13 ) diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..b0361b4 --- /dev/null +++ b/project.godot @@ -0,0 +1,42 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +_global_script_classes=[ ] +_global_script_class_icons={ + +} + +[application] + +config/name="physics object picking up" +run/main_scene="res://main.tscn" +config/icon="res://icon.png" + +[input] + +ui_accept={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null) + ] +} +left_click={ +"deadzone": 0.5, +"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) + ] +} +right_click={ +"deadzone": 0.5, +"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null) + ] +} + +[rendering] + +environment/default_environment="res://default_env.tres"