mirror of
https://github.com/Steffo99/swear-jar.git
synced 2024-11-25 09:04:19 +00:00
"Fix" physics
This commit is contained in:
parent
aa90d5a797
commit
5f5337c91f
8 changed files with 37 additions and 13 deletions
|
@ -22,4 +22,4 @@ collision_layer = 3
|
||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
|
|
||||||
[node name="Poly" type="CollisionPolygon2D" parent="StaticBody2D"]
|
[node name="Poly" type="CollisionPolygon2D" parent="StaticBody2D"]
|
||||||
polygon = PackedVector2Array(-64, -480, -64, -416, -128, -416, -128, 0, 128, 0, 128, -416, 64, -416, 64, -480, 48, -480, 48, -400, 112, -400, 112, -16, -112, -16, -112, -400, -48, -400, -48, -480)
|
polygon = PackedVector2Array(-320, -576, -320, 192, 320, 192, 320, -576, 48, -576, 48, -400, 112, -400, 112, -16, -112, -16, -112, -400, -48, -400, -48, -576)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
[gd_resource type="PhysicsMaterial" format=3 uid="uid://wjrjkmxp41dt"]
|
[gd_resource type="PhysicsMaterial" format=3 uid="uid://c6kn1an85lccr"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
rough = true
|
friction = 0.5
|
||||||
|
bounce = 0.1
|
||||||
|
|
5
entity/coin_copper.gd
Normal file
5
entity/coin_copper.gd
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
extends RigidBody2D
|
||||||
|
class CoinCopper
|
||||||
|
|
||||||
|
|
||||||
|
func _integrate_forces(state: PhysicsDirectBodyState2D):
|
|
@ -1,8 +1,9 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://c3kitncwpi42j"]
|
[gd_scene load_steps=6 format=3 uid="uid://c3kitncwpi42j"]
|
||||||
|
|
||||||
[ext_resource type="PhysicsMaterial" uid="uid://wjrjkmxp41dt" path="res://entity/coin.tres" id="1_1merf"]
|
[ext_resource type="PhysicsMaterial" uid="uid://c6kn1an85lccr" path="res://entity/coin.tres" id="1_1merf"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dbdkb4vt7dh85" path="res://entity/coin_copper_4.png" id="1_wedw1"]
|
[ext_resource type="Texture2D" uid="uid://dbdkb4vt7dh85" path="res://entity/coin_copper_4.png" id="1_wedw1"]
|
||||||
[ext_resource type="Texture2D" uid="uid://2vtvoj6ua3cb" path="res://entity/coin_copper_outline_2.png" id="2_2ifq3"]
|
[ext_resource type="Texture2D" uid="uid://2vtvoj6ua3cb" path="res://entity/coin_copper_outline_2.png" id="2_2ifq3"]
|
||||||
|
[ext_resource type="Script" path="res://entity/coin_copper.gd" id="2_y0e7k"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"]
|
||||||
size = Vector2(14, 3)
|
size = Vector2(14, 3)
|
||||||
|
@ -10,15 +11,15 @@ size = Vector2(14, 3)
|
||||||
[node name="CoinCopper" type="RigidBody2D"]
|
[node name="CoinCopper" type="RigidBody2D"]
|
||||||
collision_layer = 5
|
collision_layer = 5
|
||||||
collision_mask = 7
|
collision_mask = 7
|
||||||
center_of_mass_mode = 1
|
inertia = 20000.0
|
||||||
center_of_mass = Vector2(10, 0)
|
|
||||||
physics_material_override = ExtResource("1_1merf")
|
physics_material_override = ExtResource("1_1merf")
|
||||||
continuous_cd = 1
|
continuous_cd = 1
|
||||||
linear_damp = 0.1
|
linear_damp = 0.1
|
||||||
angular_damp = 0.1
|
angular_damp = 0.1
|
||||||
|
script = ExtResource("2_y0e7k")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
scale = Vector2(2, 2)
|
scale = Vector2(3, 3)
|
||||||
shape = SubResource("RectangleShape2D_c6byl")
|
shape = SubResource("RectangleShape2D_c6byl")
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="CollisionShape2D"]
|
[node name="Sprite" type="Sprite2D" parent="CollisionShape2D"]
|
||||||
|
|
|
@ -32,6 +32,11 @@ window/handheld/orientation=1
|
||||||
2d_physics/layer_2="Bottle"
|
2d_physics/layer_2="Bottle"
|
||||||
2d_physics/layer_3="Entities"
|
2d_physics/layer_3="Entities"
|
||||||
|
|
||||||
|
[physics]
|
||||||
|
|
||||||
|
2d/solver/contact_max_allowed_penetration=1.0
|
||||||
|
2d/solver/default_contact_bias=1.0
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
renderer/rendering_method="mobile"
|
renderer/rendering_method="mobile"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://cbccs6kwwf265"]
|
[gd_scene load_steps=4 format=3 uid="uid://cbccs6kwwf265"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" path="res://bottle/bottle.tscn" id="1_4fmd3"]
|
[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"]
|
[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"]
|
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"]
|
||||||
|
|
||||||
|
@ -76,6 +76,6 @@ texture_filter = 1
|
||||||
[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")]
|
[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")]
|
||||||
|
|
||||||
[node name="Spawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
[node name="Spawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
||||||
position = Vector2(-9, -333)
|
position = Vector2(2, -410)
|
||||||
scene = ExtResource("2_dv01l")
|
scene = ExtResource("2_dv01l")
|
||||||
target_parent = NodePath("..")
|
target_parent = NodePath("..")
|
||||||
|
|
|
@ -4,7 +4,9 @@ class_name Spawner
|
||||||
@export var target_parent: NodePath
|
@export var target_parent: NodePath
|
||||||
|
|
||||||
func spawn():
|
func spawn():
|
||||||
|
if len($Area2D.get_overlapping_bodies()) > 0:
|
||||||
|
return
|
||||||
|
|
||||||
var scene_instant= scene.instantiate()
|
var scene_instant= scene.instantiate()
|
||||||
scene_instant.position=Vector2.ZERO
|
scene_instant.position=Vector2.ZERO
|
||||||
add_child(scene_instant)
|
add_child(scene_instant)
|
||||||
print(scene_instant.global_position)
|
|
||||||
|
|
|
@ -1,12 +1,22 @@
|
||||||
[gd_scene load_steps=2 format=3 uid="uid://c67lfbk4gf1ga"]
|
[gd_scene load_steps=3 format=3 uid="uid://c67lfbk4gf1ga"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"]
|
[ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xnebx"]
|
||||||
|
size = Vector2(100, 20)
|
||||||
|
|
||||||
[node name="Spawner" type="Node2D"]
|
[node name="Spawner" type="Node2D"]
|
||||||
script = ExtResource("1_xqfmg")
|
script = ExtResource("1_xqfmg")
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="."]
|
[node name="Timer" type="Timer" parent="."]
|
||||||
wait_time = 0.008
|
wait_time = 0.02
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
|
[node name="Area2D" type="Area2D" parent="."]
|
||||||
|
collision_mask = 4
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||||
|
position = Vector2(0, -10)
|
||||||
|
shape = SubResource("RectangleShape2D_xnebx")
|
||||||
|
|
||||||
[connection signal="timeout" from="Timer" to="." method="spawn"]
|
[connection signal="timeout" from="Timer" to="." method="spawn"]
|
||||||
|
|
Loading…
Reference in a new issue