mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-07-13 02:53:48 +00:00
feat(*): Add the ability to score a goal
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://cofdcxo5170rs"]
|
[gd_scene load_steps=4 format=3 uid="uid://cofdcxo5170rs"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/goal.gd" id="1_v8ikr"]
|
||||||
|
|
||||||
[sub_resource type="BoxMesh" id="BoxMesh_4ngif"]
|
[sub_resource type="BoxMesh" id="BoxMesh_4ngif"]
|
||||||
size = Vector3(3.5, 1.5, 0.1)
|
size = Vector3(3.5, 1.5, 0.1)
|
||||||
@@ -7,9 +9,12 @@ size = Vector3(3.5, 1.5, 0.1)
|
|||||||
size = Vector3(3.5, 1.5, 0.1)
|
size = Vector3(3.5, 1.5, 0.1)
|
||||||
|
|
||||||
[node name="Goal" type="Area3D"]
|
[node name="Goal" type="Area3D"]
|
||||||
|
script = ExtResource("1_v8ikr")
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
mesh = SubResource("BoxMesh_4ngif")
|
mesh = SubResource("BoxMesh_4ngif")
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
shape = SubResource("BoxShape3D_nmd5r")
|
shape = SubResource("BoxShape3D_nmd5r")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ mesh = SubResource("SphereMesh_uxjj0")
|
|||||||
|
|
||||||
[node name="Goals" type="Node3D" parent="."]
|
[node name="Goals" type="Node3D" parent="."]
|
||||||
|
|
||||||
[node name="Goal2" parent="Goals" node_paths=PackedStringArray("ball") instance=ExtResource("3_xk008")]
|
[node name="Goal2" parent="Goals" node_paths=PackedStringArray("ball", "player1") instance=ExtResource("3_xk008")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.08165e-12, 1, -5)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.08165e-12, 1, -5)
|
||||||
script = ExtResource("4_ukkeh")
|
script = ExtResource("4_ukkeh")
|
||||||
ball = NodePath("../../Ball")
|
ball = NodePath("../../Ball")
|
||||||
|
player1 = NodePath("../../Players/Player1")
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
extends Area3D
|
extends Area3D
|
||||||
|
|
||||||
@export var ball: RigidBody3D
|
@export var ball: RigidBody3D
|
||||||
|
@export var player1: RigidBody3D
|
||||||
|
#@export var player2: RigidBody3D
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
# Called when an object with collision enters the bounds of this object
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
func _on_body_entered(body):
|
||||||
func _process(delta):
|
# Only care if it's the ball
|
||||||
if (overlaps_body(ball)):
|
if(body == ball):
|
||||||
print("Goal scored in goal 2")
|
print("Goal scored in goal 2")
|
||||||
|
# Reset the ball and player to their starting locations just for testing
|
||||||
|
ball.global_transform.origin = Vector3(0, 2, 0)
|
||||||
|
player1.global_transform.origin = Vector3(0, 0.5, 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user