Basic 3d Disc

This commit is contained in:
2023-06-04 19:28:16 -04:00
parent d881d14010
commit 86c34c9264
11 changed files with 212 additions and 14 deletions

17
3d_test.gd Normal file
View File

@@ -0,0 +1,17 @@
extends Node3D
const Disc = preload("res://disc.tscn")
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _input(event):
if event.is_action_pressed("player_jump"):
var disc = Disc.instantiate()
disc.position = $Player/Torso/RightArm/Hand.global_position
add_child(disc)
disc.apply_impulse(Vector3(0,10,0))
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

View File

@@ -1,9 +1,18 @@
[gd_scene load_steps=3 format=3 uid="uid://b6qd2ja2kaul8"] [gd_scene load_steps=6 format=3 uid="uid://b6qd2ja2kaul8"]
[ext_resource type="Script" path="res://3d_test.gd" id="1_o7asi"]
[ext_resource type="PackedScene" uid="uid://ctgbbvgfnocql" path="res://player3d.tscn" id="1_osef0"] [ext_resource type="PackedScene" uid="uid://ctgbbvgfnocql" path="res://player3d.tscn" id="1_osef0"]
[ext_resource type="PackedScene" uid="uid://fjxeinktml2j" path="res://map_3d_test.tscn" id="2_3miw1"] [ext_resource type="PackedScene" uid="uid://fjxeinktml2j" path="res://map_3d_test.tscn" id="2_3miw1"]
[ext_resource type="Script" path="res://map_3d_test.gd" id="3_15ip2"]
[ext_resource type="PackedScene" uid="uid://cb4hfwfbpcqy4" path="res://box_obstacle.tscn" id="3_qc72a"]
[node name="Node3D" type="Node3D"] [node name="Node3D" type="Node3D"]
script = ExtResource("1_o7asi")
[node name="Sun" type="DirectionalLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 9.82951, 0)
shadow_enabled = true
directional_shadow_pancake_size = 0.0
[node name="Player" parent="." instance=ExtResource("1_osef0")] [node name="Player" parent="." instance=ExtResource("1_osef0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.58914, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.58914, 0)
@@ -12,7 +21,16 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.58914, 0)
transform = Transform3D(1, 0, 0, 0, 0.979855, 0.19971, 0, -0.19971, 0.979855, 0, 1.43735, 2.24099) transform = Transform3D(1, 0, 0, 0, 0.979855, 0.19971, 0, -0.19971, 0.979855, 0, 1.43735, 2.24099)
[node name="TestTerrain" parent="." instance=ExtResource("2_3miw1")] [node name="TestTerrain" parent="." instance=ExtResource("2_3miw1")]
script = ExtResource("3_15ip2")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="TestTerrain"] [node name="Box" parent="." instance=ExtResource("3_qc72a")]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 9.82951, 0) transform = Transform3D(1, 0, 0, 0, -1, -8.74228e-08, 0, 8.74228e-08, -1, 20.5883, 0.829506, -4.05434)
shadow_enabled = true
[node name="Box2" parent="." instance=ExtResource("3_qc72a")]
transform = Transform3D(1, 0, 0, 0, -1, -8.74228e-08, 0, 8.74228e-08, -1, 7.65501, 0.829506, 7.05613)
[node name="Box3" parent="." instance=ExtResource("3_qc72a")]
transform = Transform3D(1, 0, 0, 0, -1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0.829506, -6)
[node name="Box4" parent="." instance=ExtResource("3_qc72a")]
transform = Transform3D(1, 0, 0, 0, -1, -8.74228e-08, 0, 8.74228e-08, -1, -10.006, 0.829506, -6)

11
3dobstacle.gd Normal file
View File

@@ -0,0 +1,11 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

View File

@@ -3,25 +3,26 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://bbmlq6lulxkdc" uid="uid://bbmlq6lulxkdc"
path="res://.godot/imported/TileMap.png-b7cc102f901c5c8b07c5f5b72d97252e.ctex" path.s3tc="res://.godot/imported/TileMap.png-b7cc102f901c5c8b07c5f5b72d97252e.s3tc.ctex"
metadata={ metadata={
"vram_texture": false "imported_formats": ["s3tc_bptc"],
"vram_texture": true
} }
[deps] [deps]
source_file="res://art/TileMap.png" source_file="res://art/TileMap.png"
dest_files=["res://.godot/imported/TileMap.png-b7cc102f901c5c8b07c5f5b72d97252e.ctex"] dest_files=["res://.godot/imported/TileMap.png-b7cc102f901c5c8b07c5f5b72d97252e.s3tc.ctex"]
[params] [params]
compress/mode=0 compress/mode=2
compress/high_quality=false compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_compression=1 compress/hdr_compression=1
compress/normal_map=0 compress/normal_map=0
compress/channel_pack=0 compress/channel_pack=0
mipmaps/generate=false mipmaps/generate=true
mipmaps/limit=-1 mipmaps/limit=-1
roughness/mode=0 roughness/mode=0
roughness/src_normal="" roughness/src_normal=""
@@ -31,4 +32,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false process/hdr_as_srgb=false
process/hdr_clamp_exposure=false process/hdr_clamp_exposure=false
process/size_limit=0 process/size_limit=0
detect_3d/compress_to=1 detect_3d/compress_to=0

15
box_obstacle.tscn Normal file
View File

@@ -0,0 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://cb4hfwfbpcqy4"]
[sub_resource type="BoxMesh" id="BoxMesh_mpwqk"]
size = Vector3(1, 2, 1)
[sub_resource type="BoxShape3D" id="BoxShape3D_ocyf5"]
size = Vector3(1, 2, 1)
[node name="StaticBody3D" type="StaticBody3D"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("BoxMesh_mpwqk")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("BoxShape3D_ocyf5")

18
disc.tscn Normal file
View File

@@ -0,0 +1,18 @@
[gd_scene load_steps=3 format=3 uid="uid://bm6vv074tk0nx"]
[sub_resource type="CylinderMesh" id="CylinderMesh_f68ox"]
top_radius = 0.25
bottom_radius = 0.25
height = 0.05
[sub_resource type="CylinderShape3D" id="CylinderShape3D_6l5gm"]
height = 0.05
radius = 0.25
[node name="Disc" type="RigidBody3D"]
[node name="Model" type="MeshInstance3D" parent="."]
mesh = SubResource("CylinderMesh_f68ox")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CylinderShape3D_6l5gm")

11
map_3d_test.gd Normal file
View File

@@ -0,0 +1,11 @@
extends StaticBody3D
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

View File

@@ -1,9 +1,17 @@
[gd_scene load_steps=2 format=3 uid="uid://fjxeinktml2j"] [gd_scene load_steps=4 format=3 uid="uid://fjxeinktml2j"]
[sub_resource type="PlaneMesh" id="PlaneMesh_763vg"] [sub_resource type="PlaneMesh" id="PlaneMesh_763vg"]
size = Vector2(100, 100) size = Vector2(100, 100)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_2fd53"]
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_xh6w0"]
[node name="Terrain" type="StaticBody3D"] [node name="Terrain" type="StaticBody3D"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="."] [node name="Plane" type="MeshInstance3D" parent="."]
mesh = SubResource("PlaneMesh_763vg") mesh = SubResource("PlaneMesh_763vg")
surface_material_override/0 = SubResource("StandardMaterial3D_2fd53")
[node name="WorldPlane" type="CollisionShape3D" parent="."]
shape = SubResource("WorldBoundaryShape3D_xh6w0")

49
player3d.gd Normal file
View File

@@ -0,0 +1,49 @@
extends CharacterBody3D
var remote_player = false
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _input(event):
pass
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
# Handle Jump.
if Input.is_action_just_pressed("player_jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir = Input.get_vector("player_left", "player_right", "player_up", "player_down")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
var flick = Input.get_vector(
"flick_left",
"flick_right",
"flick_up",
"flick_down"
)
var flick_ang :float= 0
if flick.length_squared() != 0:
flick_ang = flick.angle()
var flick_rot = Vector3(0,0,flick_ang)
$Torso/LeftArm.rotation = flick_rot
$Torso/RightArm.rotation = -flick_rot
move_and_slide()

View File

@@ -1,14 +1,58 @@
[gd_scene load_steps=3 format=3 uid="uid://ctgbbvgfnocql"] [gd_scene load_steps=6 format=3 uid="uid://ctgbbvgfnocql"]
[ext_resource type="Script" path="res://player3d.gd" id="1_8eds3"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vyj2w"] [sub_resource type="BoxShape3D" id="BoxShape3D_vyj2w"]
size = Vector3(1, 2, 1) size = Vector3(1, 2, 1)
[sub_resource type="CapsuleMesh" id="CapsuleMesh_8g2hv"] [sub_resource type="CapsuleMesh" id="CapsuleMesh_8g2hv"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_1k7yw"]
radius = 0.175
height = 1.25
[sub_resource type="SphereShape3D" id="SphereShape3D_1okp8"]
radius = 0.25
[node name="Player" type="CharacterBody3D"] [node name="Player" type="CharacterBody3D"]
script = ExtResource("1_8eds3")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("BoxShape3D_vyj2w") shape = SubResource("BoxShape3D_vyj2w")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."] [node name="Torso" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
mesh = SubResource("CapsuleMesh_8g2hv") mesh = SubResource("CapsuleMesh_8g2hv")
[node name="LeftArm" type="Node3D" parent="Torso"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 0.2, 0)
[node name="Arm" type="MeshInstance3D" parent="Torso/LeftArm"]
transform = Transform3D(-4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, -0.4, 0, 0)
mesh = SubResource("CapsuleMesh_1k7yw")
skeleton = NodePath("../../..")
[node name="LeftHand" type="StaticBody3D" parent="Torso/LeftArm"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, 0)
collision_layer = 2
collision_mask = 2
[node name="LeftHand" type="CollisionShape3D" parent="Torso/LeftArm/LeftHand"]
shape = SubResource("SphereShape3D_1okp8")
[node name="RightArm" type="Node3D" parent="Torso"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.2, 0)
[node name="Arm" type="MeshInstance3D" parent="Torso/RightArm"]
transform = Transform3D(-4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0.4, 0, 0)
mesh = SubResource("CapsuleMesh_1k7yw")
skeleton = NodePath("../../..")
[node name="Hand" type="StaticBody3D" parent="Torso/RightArm"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0)
collision_layer = 2
collision_mask = 2
[node name="Hand" type="CollisionShape3D" parent="Torso/RightArm/Hand"]
shape = SubResource("SphereShape3D_1okp8")

View File

@@ -53,6 +53,12 @@ player_down={
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
] ]
} }
player_jump={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
]
}
flick_up={ flick_up={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null) "events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)