prototype of guest pickup

This commit is contained in:
mightypanders 2021-06-12 13:41:12 +02:00
parent f01ca9d80c
commit ec42bd1672
2 changed files with 47 additions and 12 deletions

View File

@ -5,11 +5,36 @@ export var MAX_SPEED = 100
export var FRICTION = 30 export var FRICTION = 30
var velocity = Vector2.ZERO var velocity = Vector2.ZERO
var last_in_line
var guests = []
func _ready(): func _ready():
last_in_line = $Anchor
pass # Replace with function body. 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): func _physics_process(delta):
var direction = Vector2.UP.rotated(rotation).normalized() #Playerrotation nehmen ist sicherer var direction = Vector2.UP.rotated(rotation).normalized() #Playerrotation nehmen ist sicherer
@ -24,7 +49,7 @@ func _physics_process(delta):
if steer_dir != 0: if steer_dir != 0:
var direction_new = direction.rotated(PI/2 * steer_dir * delta) 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()))) #print(velocity.angle_to(velocity.rotated(direction_new.angle())))
velocity = velocity.rotated(direction.angle_to(direction_new)) velocity = velocity.rotated(direction.angle_to(direction_new))
rotate(direction.angle_to(direction_new)) rotate(direction.angle_to(direction_new))

View File

@ -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] [ext_resource path="res://Playa.gd" type="Script" id=2]
[sub_resource type="CapsuleShape2D" id=1] [sub_resource type="CapsuleShape2D" id=1]
radius = 33.6545 radius = 13.0017
height = 72.4629 height = 19.9256
[sub_resource type="CapsuleShape2D" id=2] [sub_resource type="CapsuleShape2D" id=2]
radius = 33.5246 radius = 12.9279
height = 72.4617 height = 25.8183
[sub_resource type="CapsuleShape2D" id=3]
radius = 5.0
height = 4.0
[node name="Playa" type="KinematicBody2D" groups=[ [node name="Playa" type="KinematicBody2D" groups=[
"Player", "Player",
]] ]]
script = ExtResource( 2 ) script = ExtResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="Sprite" type="Sprite" parent="."] [node name="Sprite" type="Sprite" parent="."]
position = Vector2( 5.25562, -20.8122 )
rotation = 3.14159 rotation = 3.14159
scale = Vector2( 2, 2 ) scale = Vector2( 0.1, 0.1 )
texture = ExtResource( 1 ) texture = ExtResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
@ -33,4 +33,14 @@ shape = SubResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="PickupCheckArea"] [node name="CollisionShape2D" type="CollisionShape2D" parent="PickupCheckArea"]
shape = SubResource( 2 ) 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"] [connection signal="area_entered" from="PickupCheckArea" to="." method="_on_PickupCheckArea_area_entered"]