How I got this ? The easier way for me to explain would be to share the project, but I just realize that there is no way to upload zip files here… so here are the scripts:
extends Node2D
var counter = 0
var previous_try_frames = 0
var sc_scene = preload("res://first/sc.tscn")
const END_TIME = 4
const fps_list = [6, 30, 60, 120]
func _ready() -> void:
print(" -- capture positions at ", END_TIME, "s -- ")
Engine.physics_ticks_per_second = fps_list[counter]
func _physics_process(delta: float) -> void:
if Engine.get_physics_frames() - previous_try_frames == Engine.physics_ticks_per_second * END_TIME:
get_child(0).name = "Sc"
print("\n - ", "at ", Engine.physics_ticks_per_second, " physics fps")
print(" ----- with move_and_slide:")
print("position.x = ", $Sc/CharacterBody2D.position.x)
print("position.x = ", $Sc/CharacterBody2D2.position.x, " <--before and after")
print(" ----- with move_and_collide:")
print("position.x = ", $Sc/MvCollide.position.x)
print("position.x = ", $Sc/MvCollide2.position.x, " <--before and after")
counter += 1
if counter >= fps_list.size():
print("\n -- END -- ")
return
Engine.physics_ticks_per_second = fps_list[counter]
previous_try_frames = Engine.get_physics_frames()
$Sc.queue_free()
add_child(sc_scene.instantiate())
# name: CharacterBody2D
extends CharacterBody2D
@onready var acceleration = get_parent().get_meta("acceleration")
func _physics_process(delta: float) -> void:
velocity.x += acceleration * delta
move_and_slide()
# name: CharacterBody2D2
extends CharacterBody2D
@onready var acceleration = get_parent().get_meta("acceleration")
func _physics_process(delta: float) -> void:
velocity.x += acceleration * delta * 0.5
move_and_slide()
velocity.x += acceleration * delta * 0.5
# name: MvCollide
extends CharacterBody2D
@onready var acceleration = get_parent().get_meta("acceleration")
func _physics_process(delta: float) -> void:
velocity.x += acceleration * delta
move_and_collide(velocity * delta)
# name: MvCollide2
extends CharacterBody2D
@onready var acceleration = get_parent().get_meta("acceleration")
func _physics_process(delta: float) -> void:
velocity.x += acceleration * delta * 0.5
move_and_collide(velocity * delta)
velocity.x += acceleration * delta * 0.5
and the tree:
Sorry, I know it is not very clean code…