From ec42bd167240f07e2831d11a08ffebac2fc0c688 Mon Sep 17 00:00:00 2001 From: mightypanders Date: Sat, 12 Jun 2021 13:41:12 +0200 Subject: [PATCH] prototype of guest pickup --- Playa.gd | 27 ++++++++++++++++++++++++++- Playa.tscn | 32 +++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/Playa.gd b/Playa.gd index f72a379..be250de 100644 --- a/Playa.gd +++ b/Playa.gd @@ -5,11 +5,36 @@ export var MAX_SPEED = 100 export var FRICTION = 30 var velocity = Vector2.ZERO +var last_in_line +var guests = [] func _ready(): + last_in_line = $Anchor pass # Replace with function body. +func add_Guest_to_Line(parent,guest): + guests.append(guest) + var joint = parent.get_node("CollisionShape2D/Joint") + joint.add_child(guest) + joint.node_a = parent.get_path() + joint.node_b = guest.get_path() + return guest + +func _on_PickupCheckArea_area_entered(area): + + if area.get_parent().is_in_group("DropOffPoint"): + print("It's a DOP") + #drop all guests after first guest.color == DOP.color, also vanish all guests.color == DOP.color + pass + if area.get_parent().is_in_group("Guest"): + print("It's a Guest") + last_in_line = add_Guest_to_Line(last_in_line,area.get_parent()) + print(last_in_line) + + print(guests) + + func _physics_process(delta): var direction = Vector2.UP.rotated(rotation).normalized() #Playerrotation nehmen ist sicherer @@ -24,7 +49,7 @@ func _physics_process(delta): if steer_dir != 0: var direction_new = direction.rotated(PI/2 * steer_dir * delta) - print(PI/8 * delta) + #print(PI/8 * delta) #print(velocity.angle_to(velocity.rotated(direction_new.angle()))) velocity = velocity.rotated(direction.angle_to(direction_new)) rotate(direction.angle_to(direction_new)) diff --git a/Playa.tscn b/Playa.tscn index 9e02a6c..347126e 100644 --- a/Playa.tscn +++ b/Playa.tscn @@ -1,28 +1,28 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] -[ext_resource path="res://assets/car/Auto.png" type="Texture" id=1] +[ext_resource path="res://assets/car/Autoi cut.png" type="Texture" id=1] [ext_resource path="res://Playa.gd" type="Script" id=2] [sub_resource type="CapsuleShape2D" id=1] -radius = 33.6545 -height = 72.4629 +radius = 13.0017 +height = 19.9256 [sub_resource type="CapsuleShape2D" id=2] -radius = 33.5246 -height = 72.4617 +radius = 12.9279 +height = 25.8183 + +[sub_resource type="CapsuleShape2D" id=3] +radius = 5.0 +height = 4.0 [node name="Playa" type="KinematicBody2D" groups=[ "Player", ]] script = ExtResource( 2 ) -__meta__ = { -"_edit_group_": true -} [node name="Sprite" type="Sprite" parent="."] -position = Vector2( 5.25562, -20.8122 ) rotation = 3.14159 -scale = Vector2( 2, 2 ) +scale = Vector2( 0.1, 0.1 ) texture = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] @@ -33,4 +33,14 @@ shape = SubResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="PickupCheckArea"] shape = SubResource( 2 ) +[node name="Anchor" type="Area2D" parent="."] +position = Vector2( 0, 25 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Anchor"] +shape = SubResource( 3 ) + +[node name="Joint" type="PinJoint2D" parent="Anchor/CollisionShape2D"] +node_a = NodePath("../../..") +softness = 2.0 + [connection signal="area_entered" from="PickupCheckArea" to="." method="_on_PickupCheckArea_area_entered"]