Skip to content

Commit

Permalink
Enable physics interpolation in all demos that use physics
Browse files Browse the repository at this point in the history
This also improves visuals in the Voxel and Dynamic Split Screen demos,
and fixes splitscreen mode in the Platformer 2D demo.

Most demos (other than physics tests) have also had their physics FPS
increased to 120. This is done consistency with 4.x, but also for the
benefits it still provides when interpolation are enabled
(lower input lag, more stable simulation).
  • Loading branch information
Calinou committed Jun 6, 2024
1 parent d52d430 commit 9ee27c8
Show file tree
Hide file tree
Showing 48 changed files with 152 additions and 77 deletions.
3 changes: 0 additions & 3 deletions 2d/finite_state_machine/Demo.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ __meta__ = {
[node name="Control" type="Control" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="StatesStackDiplayer" parent="Control" instance=ExtResource( 3 )]

Expand Down
4 changes: 1 addition & 3 deletions 2d/finite_state_machine/player/Player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ position = Vector2( 110, 0 )
polygon = PoolVector2Array( -20, 0, -20, -20, 20, -20, 20, 0 )

[node name="StateNameDisplayer" type="Label" parent="."]
physics_interpolation_mode = 2
margin_left = -109.0
margin_top = -172.0
margin_right = 110.0
Expand All @@ -114,9 +115,6 @@ align = 1
valign = 1
uppercase = true
script = ExtResource( 15 )
__meta__ = {
"_edit_use_anchors_": false
}

[connection signal="state_changed" from="StateMachine" to="BodyPivot/WeaponPivot/Offset/Sword" method="_on_StateMachine_state_changed"]
[connection signal="state_changed" from="StateMachine" to="StateNameDisplayer" method="_on_StateMachine_state_changed"]
Expand Down
2 changes: 1 addition & 1 deletion 2d/finite_state_machine/player/bullet/bullet_spawner.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ func fire():

$CooldownTimer.start()
var new_bullet = bullet.instance()
add_child(new_bullet)
new_bullet.position = global_position
new_bullet.direction = owner.look_direction
add_child(new_bullet)
4 changes: 4 additions & 0 deletions 2d/finite_state_machine/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ attack={
]
}

[physics]

common/physics_interpolation=true

[rendering]

quality/driver/driver_name="GLES2"
Expand Down
5 changes: 5 additions & 0 deletions 2d/hexagonal_map/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ move_up={
]
}

[physics]

common/physics_fps=120
common/physics_interpolation=true

[rendering]

quality/driver/driver_name="GLES2"
Expand Down
1 change: 1 addition & 0 deletions 2d/hexagonal_map/troll.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ shape = SubResource( 1 )

[node name="Camera2D" type="Camera2D" parent="."]
current = true
process_mode = 0
5 changes: 0 additions & 5 deletions 2d/isometric/dungeon.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -1581,37 +1581,32 @@ material = SubResource( 41 )
position = Vector2( 445, -129 )
frames = SubResource( 40 )
animation = "sleep"
frame = 1
playing = true

[node name="CrowSleep2" type="AnimatedSprite" parent="Crows"]
material = SubResource( 42 )
position = Vector2( 108, 481 )
frames = SubResource( 40 )
animation = "sleep"
frame = 1
playing = true
flip_h = true

[node name="CrowLook" type="AnimatedSprite" parent="Crows"]
position = Vector2( -168, -145 )
frames = SubResource( 91 )
animation = "looking"
frame = 7
playing = true
flip_h = true

[node name="CrowLook2" type="AnimatedSprite" parent="Crows"]
position = Vector2( 1782, 35 )
frames = SubResource( 91 )
animation = "looking"
frame = 7
playing = true
flip_h = true

[node name="CrowLook3" type="AnimatedSprite" parent="Crows"]
position = Vector2( 1024, 78 )
frames = SubResource( 91 )
animation = "looking"
frame = 7
playing = true
2 changes: 1 addition & 1 deletion 2d/isometric/player/goblin.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,6 @@ position = Vector2( 0, -35 )
scale = Vector2( 0.8, 0.8 )
frames = SubResource( 260 )
animation = "front_idle"
frame = 8
playing = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
Expand All @@ -1406,6 +1405,7 @@ shape = SubResource( 1 )

[node name="Camera2D" type="Camera2D" parent="."]
current = true
process_mode = 0

[node name="LightOccluder2D" type="LightOccluder2D" parent="."]
light_mask = 16
Expand Down
5 changes: 5 additions & 0 deletions 2d/isometric/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ move_up={
]
}

[physics]

common/physics_fps=120
common/physics_interpolation=true

[rasterizer]

use_pixel_snap=true
Expand Down
2 changes: 2 additions & 0 deletions 2d/kinematic_character/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ multithread/thread_rid_pool_prealloc=60

[physics]

common/physics_fps=120
2d/default_gravity=500
common/physics_interpolation=true

[rendering]

Expand Down
37 changes: 26 additions & 11 deletions 2d/kinematic_character/world.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=19 format=2]
[gd_scene load_steps=20 format=2]

[ext_resource path="res://level/obstacle.png" type="Texture" id=2]
[ext_resource path="res://player/player.tscn" type="PackedScene" id=3]
Expand Down Expand Up @@ -36,6 +36,21 @@ extents = Vector2( 8, 8 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 8, 8 )

[sub_resource type="Animation" id=13]
resource_name = "RESET"
tracks/0/type = "value"
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector2( 184, 152 ) ]
}

[sub_resource type="Animation" id=4]
length = 10.0
loop = true
Expand All @@ -52,21 +67,19 @@ tracks/0/keys = {
"values": [ Vector2( 184, 152 ), Vector2( 184, 152 ), Vector2( 328.086, 152 ), Vector2( 328.086, 152 ) ]
}

[sub_resource type="Animation" id=5]
resource_name = "leftright"
length = 10.0
loop = true
[sub_resource type="Animation" id=14]
resource_name = "RESET"
tracks/0/type = "value"
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1, 5, 6 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector2( 184, 152 ), Vector2( 184, 152 ), Vector2( 328.086, 152 ), Vector2( 328.086, 152 ) ]
"values": [ Vector2( 88.3493, 296 ) ]
}

[sub_resource type="Animation" id=6]
Expand Down Expand Up @@ -128,7 +141,7 @@ tile_data = PoolIntArray( -720908, 0, 0, -720907, 0, 0, -720906, 0, 0, -720905,
position = Vector2( 233.06, 223.436 )

[node name="MovingPlatform1" type="KinematicBody2D" parent="."]
position = Vector2( 274.142, 152 )
position = Vector2( 184, 152 )

[node name="Collision" type="CollisionShape2D" parent="MovingPlatform1"]
shape = SubResource( 3 )
Expand All @@ -139,10 +152,11 @@ texture = ExtResource( 2 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="MovingPlatform1"]
autoplay = "leftright"
playback_process_mode = 0
anims/RESET = SubResource( 13 )
anims/leftright = SubResource( 4 )

[node name="MovingPlatform2" type="KinematicBody2D" parent="."]
position = Vector2( 88.3493, 284.689 )
position = Vector2( 88.3493, 296 )

[node name="Collision" type="CollisionShape2D" parent="MovingPlatform2"]
shape = SubResource( 3 )
Expand All @@ -153,7 +167,7 @@ texture = ExtResource( 2 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="MovingPlatform2"]
autoplay = "updown"
playback_process_mode = 0
anims/leftright = SubResource( 5 )
anims/RESET = SubResource( 14 )
anims/updown = SubResource( 6 )

[node name="Princess" type="Area2D" parent="."]
Expand Down Expand Up @@ -266,5 +280,6 @@ shape = SubResource( 12 )
[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2( 265, 247 )
current = true
process_mode = 0

[connection signal="body_entered" from="Princess" to="Princess" method="_on_body_entered"]
3 changes: 2 additions & 1 deletion 2d/navigation/level.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ position = Vector2( 429.585, 287.32 )
texture = ExtResource( 2 )

[node name="Character" type="Sprite" parent="."]
position = Vector2( 228.464, 132.594 )
position = Vector2( 202, 100 )
scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 3 )
offset = Vector2( 0, -26 )
Expand All @@ -36,3 +36,4 @@ default_color = Color( 1, 0, 0, 1 )
[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2( 420, 300 )
current = true
process_mode = 0
7 changes: 6 additions & 1 deletion 2d/navigation/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ singletons=[ ]

click={
"deadzone": 0.5,
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"doubleclick":false,"script":null)
]
}

[physics]

common/physics_fps=120
common/physics_interpolation=true

[rendering]

quality/driver/driver_name="GLES2"
Expand Down
1 change: 1 addition & 0 deletions 2d/physics_platformer/player/Player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ anims/standing_weapon_ready = SubResource( 12 )
[node name="Camera" type="Camera2D" parent="."]
current = true
zoom = Vector2( 0.5, 0.5 )
process_mode = 0
limit_left = 0
limit_top = 0

Expand Down
4 changes: 3 additions & 1 deletion 2d/physics_platformer/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ shoot={
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":7,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"doubleclick":false,"script":null)
]
}
spawn={
Expand All @@ -142,7 +142,9 @@ spawn={

[physics]

common/physics_fps=120
2d/default_gravity=900
common/physics_interpolation=true

[rasterizer]

Expand Down
8 changes: 4 additions & 4 deletions 2d/physics_tests/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ config/icon="res://icon.png"
Log="*res://utils/system_log.gd"
System="*res://utils/system.gd"

[debug]

gdscript/warnings/return_value_discarded=false

[display]

window/dpi/allow_hidpi=true
Expand Down Expand Up @@ -123,6 +119,10 @@ character_jump={

limits/message_queue/max_size_kb=10240

[physics]

common/physics_interpolation=true

[rendering]

quality/driver/driver_name="GLES2"
Expand Down
4 changes: 3 additions & 1 deletion 2d/platformer/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ shoot={
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"doubleclick":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777350,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777238,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
Expand Down Expand Up @@ -228,7 +228,9 @@ splitscreen={

[physics]

common/physics_fps=120
2d/default_gravity=1400
common/physics_interpolation=true

[rasterizer]

Expand Down
4 changes: 4 additions & 0 deletions 2d/platformer/src/actors/player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ position = Vector2( 0, -28 )
offset = Vector2( 0, 50 )
current = true
process_mode = 0
limit_left = -315
limit_top = -250
limit_right = 955
limit_bottom = 690

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0, -14 )
Expand Down
16 changes: 0 additions & 16 deletions 2d/platformer/src/level/level.gd
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
extends Node2D


const LIMIT_LEFT = -315
const LIMIT_TOP = -250
const LIMIT_RIGHT = 955
const LIMIT_BOTTOM = 690


func _ready():
for child in get_children():
if child is Player:
var camera = child.get_node("Camera")
camera.limit_left = LIMIT_LEFT
camera.limit_top = LIMIT_TOP
camera.limit_right = LIMIT_RIGHT
camera.limit_bottom = LIMIT_BOTTOM
4 changes: 2 additions & 2 deletions 2d/platformer/src/main/game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func _unhandled_input(event):
$Black/SplitContainer/ViewportContainer1.free()
$Black.queue_free()
# warning-ignore:return_value_discarded
get_tree().change_scene("res://src/Main/Game.tscn")
get_tree().change_scene("res://src/main/game.tscn")
else:
# warning-ignore:return_value_discarded
get_tree().change_scene("res://src/Main/Splitscreen.tscn")
get_tree().change_scene("res://src/main/split_screen.tscn")
2 changes: 1 addition & 1 deletion 2d/platformer/src/main/game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ script = ExtResource( 2 )
z_index = -1

[node name="Player" parent="Level" instance=ExtResource( 4 )]
position = Vector2( 157, 648 )
position = Vector2( 157, 636.5 )
scale = Vector2( 1, 1 )
z_index = 3

Expand Down
8 changes: 6 additions & 2 deletions 2d/platformer/src/main/split_screen.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ audio_listener_enable_2d = true
[node name="Level" parent="Black/SplitContainer/ViewportContainer1/Viewport1" instance=ExtResource( 3 )]

[node name="Player1" parent="Black/SplitContainer/ViewportContainer1/Viewport1/Level" instance=ExtResource( 4 )]
position = Vector2( 90, 546 )
position = Vector2( 100, 636.5 )
scale = Vector2( 1, 1 )
z_index = 3
action_suffix = "_p1"

[node name="Player2" parent="Black/SplitContainer/ViewportContainer1/Viewport1/Level" instance=ExtResource( 4 )]
position = Vector2( 120, 546 )
position = Vector2( 160, 636.5 )
scale = Vector2( 1, 1 )
z_index = 3
action_suffix = "_p2"

[node name="ViewportContainer2" type="ViewportContainer" parent="Black/SplitContainer"]
Expand Down
Loading

0 comments on commit 9ee27c8

Please sign in to comment.