mirror of
				https://github.com/mightypanders/GMTKJam2021.git
				synced 2025-11-04 02:59:50 +01:00 
			
		
		
		
	better velocity check
This commit is contained in:
		
							
								
								
									
										16
									
								
								Guest.gd
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								Guest.gd
									
									
									
									
									
								
							@@ -1,8 +1,8 @@
 | 
				
			|||||||
extends KinematicBody2D
 | 
					extends RigidBody2D
 | 
				
			||||||
 | 
					
 | 
				
			||||||
onready var pickUpArea = $PickUpArea
 | 
					onready var pickUpArea = $PickUpArea
 | 
				
			||||||
export var guestName = "Dieter"
 | 
					export var guestName = "Dieter"
 | 
				
			||||||
export var  PICKUPTRESHOLD = 5
 | 
					export var  PICKUPTRESHOLD = 80
 | 
				
			||||||
export var destinationColor = Color.yellow
 | 
					export var destinationColor = Color.yellow
 | 
				
			||||||
signal picked_up(color,name)
 | 
					signal picked_up(color,name)
 | 
				
			||||||
signal dropped_off_success 
 | 
					signal dropped_off_success 
 | 
				
			||||||
@@ -21,11 +21,15 @@ var colorList = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# 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():	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						#print(get_tree().get_root().get_node("Playa"))
 | 
				
			||||||
 | 
						#connect('picked_up',get_tree().get_nodes_in_group("Player")[0], '_on_Guest_picked_up')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rng.randomize()
 | 
						rng.randomize()
 | 
				
			||||||
	var n = rng.randi_range(0,4)
 | 
						var n = rng.randi_range(0,4)
 | 
				
			||||||
	print(n)
 | 
						#print(n)
 | 
				
			||||||
	destinationColor = colorList[n]
 | 
						destinationColor = colorList[n]
 | 
				
			||||||
	print(destinationColor)
 | 
						#print(destinationColor)
 | 
				
			||||||
	sprite.modulate = destinationColor
 | 
						sprite.modulate = destinationColor
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -35,8 +39,8 @@ func _ready():
 | 
				
			|||||||
func _on_PickUpArea_body_entered(body):
 | 
					func _on_PickUpArea_body_entered(body):
 | 
				
			||||||
	print(body.name)
 | 
						print(body.name)
 | 
				
			||||||
	if body.name == "Playa":
 | 
						if body.name == "Playa":
 | 
				
			||||||
		print(body.velocity)
 | 
							print(body.velocity.length())
 | 
				
			||||||
		if body.velocity.x >= PICKUPTRESHOLD and body.velocity.y >= PICKUPTRESHOLD:
 | 
							if body.velocity.length() <= PICKUPTRESHOLD:
 | 
				
			||||||
			emit_signal("picked_up",destinationColor,guestName)
 | 
								emit_signal("picked_up",destinationColor,guestName)
 | 
				
			||||||
			# start pickup process
 | 
								# start pickup process
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,9 +10,10 @@ height = 3.32129
 | 
				
			|||||||
[sub_resource type="CircleShape2D" id=2]
 | 
					[sub_resource type="CircleShape2D" id=2]
 | 
				
			||||||
radius = 24.5545
 | 
					radius = 24.5545
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="Guest" type="KinematicBody2D" groups=[
 | 
					[node name="Guest" type="RigidBody2D" groups=[
 | 
				
			||||||
"Guest",
 | 
					"Guest",
 | 
				
			||||||
]]
 | 
					]]
 | 
				
			||||||
 | 
					mode = 2
 | 
				
			||||||
script = ExtResource( 2 )
 | 
					script = ExtResource( 2 )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="Sprite" type="Sprite" parent="."]
 | 
					[node name="Sprite" type="Sprite" parent="."]
 | 
				
			||||||
@@ -21,6 +22,9 @@ texture = ExtResource( 1 )
 | 
				
			|||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
 | 
					[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
 | 
				
			||||||
shape = SubResource( 1 )
 | 
					shape = SubResource( 1 )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[node name="Joint" type="PinJoint2D" parent="CollisionShape2D"]
 | 
				
			||||||
 | 
					node_a = NodePath("../..")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="PickUpArea" type="Area2D" parent="."]
 | 
					[node name="PickUpArea" type="Area2D" parent="."]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PickUpArea"]
 | 
					[node name="CollisionShape2D" type="CollisionShape2D" parent="PickUpArea"]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user