- Add a new "Item" physics layer - Models now include their collision shape - Item "fixes" collision shape node location - Item initializes some collision properties - Grid has been turned into a scenemain
parent
d8a9320098
commit
17da96969a
15 changed files with 98 additions and 87 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,7 +1,27 @@ |
|||||||
public partial class Item : StaticBody3D |
public partial class Item : RigidBody3D |
||||||
{ |
{ |
||||||
[Export] public Vector3I Size { get; set; } |
[Export] public Vector3I Size { get; set; } |
||||||
|
|
||||||
public virtual Node3D Model |
public virtual Node3D Model |
||||||
=> GetNode<Node3D>("Model"); |
=> GetNode<Node3D>("Model"); |
||||||
|
|
||||||
|
public override void _Ready() |
||||||
|
{ |
||||||
|
// TODO: Find a better way to better import models with colliders. |
||||||
|
// TODO: Import items dynamically at runtime? |
||||||
|
// TODO: Use PostImport tool script? |
||||||
|
foreach (var body in FindChildren("*", "StaticBody3D").Cast<StaticBody3D>()) { |
||||||
|
foreach (var shape in body.GetChildren().OfType<CollisionShape3D>()) { |
||||||
|
body.RemoveChild(shape); |
||||||
|
AddChild(shape); |
||||||
|
} |
||||||
|
body.GetParent().RemoveChild(body); |
||||||
|
} |
||||||
|
|
||||||
|
// Set the collision properties here so we don't have to specify them in each item scene separately. |
||||||
|
CollisionLayer = (uint)(PhysicsLayer.Item | PhysicsLayer.Interactable); |
||||||
|
CollisionMask = (uint)(PhysicsLayer.Static | PhysicsLayer.Dynamic | PhysicsLayer.Player | PhysicsLayer.Item); |
||||||
|
|
||||||
|
Freeze = FindParent("Grid") != null; |
||||||
|
} |
||||||
} |
} |
||||||
|
@ -1,19 +1,10 @@ |
|||||||
[gd_scene load_steps=4 format=3 uid="uid://bjgfm5x7a0dab"] |
[gd_scene load_steps=3 format=3 uid="uid://bjgfm5x7a0dab"] |
||||||
|
|
||||||
[ext_resource type="Script" path="res://objects/Item.cs" id="1_43oqr"] |
[ext_resource type="Script" path="res://objects/Item.cs" id="1_43oqr"] |
||||||
[ext_resource type="PackedScene" uid="uid://s4esxyuwyet4" path="res://assets/models/bolt.gltf" id="2_3v163"] |
[ext_resource type="PackedScene" uid="uid://s4esxyuwyet4" path="res://assets/models/bolt.gltf" id="2_3v163"] |
||||||
|
|
||||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_1yi6b"] |
[node name="Bolt" type="RigidBody3D"] |
||||||
height = 0.1 |
|
||||||
radius = 0.025 |
|
||||||
|
|
||||||
[node name="Bolt" type="StaticBody3D"] |
|
||||||
collision_layer = 9 |
|
||||||
collision_mask = 0 |
|
||||||
script = ExtResource("1_43oqr") |
script = ExtResource("1_43oqr") |
||||||
Size = Vector3i(1, 2, 1) |
Size = Vector3i(1, 2, 1) |
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] |
|
||||||
shape = SubResource("CylinderShape3D_1yi6b") |
|
||||||
|
|
||||||
[node name="Model" parent="." instance=ExtResource("2_3v163")] |
[node name="Model" parent="." instance=ExtResource("2_3v163")] |
||||||
|
@ -0,0 +1,9 @@ |
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://54575e3ygpxl"] |
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://objects/Grid.cs" id="1_7yhbt"] |
||||||
|
|
||||||
|
[node name="Grid" type="Area3D"] |
||||||
|
collision_layer = 256 |
||||||
|
collision_mask = 0 |
||||||
|
monitoring = false |
||||||
|
script = ExtResource("1_7yhbt") |
@ -1,18 +1,10 @@ |
|||||||
[gd_scene load_steps=4 format=3 uid="uid://ccprmftodum0o"] |
[gd_scene load_steps=3 format=3 uid="uid://ccprmftodum0o"] |
||||||
|
|
||||||
[ext_resource type="Script" path="res://objects/Item.cs" id="1_6pcd7"] |
[ext_resource type="Script" path="res://objects/Item.cs" id="1_6pcd7"] |
||||||
[ext_resource type="PackedScene" uid="uid://c1fi6jcly6cx2" path="res://assets/models/nail.gltf" id="2_nls7x"] |
[ext_resource type="PackedScene" uid="uid://c1fi6jcly6cx2" path="res://assets/models/nail.gltf" id="2_nls7x"] |
||||||
|
|
||||||
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_wqf35"] |
[node name="Nail" type="RigidBody3D"] |
||||||
points = PackedVector3Array(-0.025, 0.05, -0.025, 0.025, 0.05, -0.025, 0.025, 0.05, 0.025, -0.025, 0.05, 0.025, 0, -0.05, 0) |
|
||||||
|
|
||||||
[node name="Nail" type="StaticBody3D"] |
|
||||||
collision_layer = 9 |
|
||||||
collision_mask = 0 |
|
||||||
script = ExtResource("1_6pcd7") |
script = ExtResource("1_6pcd7") |
||||||
Size = Vector3i(1, 2, 1) |
Size = Vector3i(1, 2, 1) |
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] |
|
||||||
shape = SubResource("ConvexPolygonShape3D_wqf35") |
|
||||||
|
|
||||||
[node name="Model" parent="." instance=ExtResource("2_nls7x")] |
[node name="Model" parent="." instance=ExtResource("2_nls7x")] |
||||||
|
Loading…
Reference in new issue