03-13-2024, 11:11 AM
I found a post on the sonic forums that tries to convert the SMB3 physics chart to floating point values here...
https://forums.sonicretro.org/index.php?...ide.34457/
But it seems it practice to not be accurate. These values tend to make mario a bit slower then what he is in the official game.
I did multiply the values by 60 and then multiply them by get_time_scale which is this function here...
Is there a reason why these values are off?
Maybe I'm not applying deceleration correctly?
Note this is gdscript.
https://forums.sonicretro.org/index.php?...ide.34457/
But it seems it practice to not be accurate. These values tend to make mario a bit slower then what he is in the official game.
I did multiply the values by 60 and then multiply them by get_time_scale which is this function here...
Code:
func get_time_scale(delta:float)->float:
return delta/(1.0/60.0)
Is there a reason why these values are off?
Maybe I'm not applying deceleration correctly?
Code:
extends CharacterBody2D
@onready var animator1 : AnimationPlayer = $Animator1
@onready var animator2 : AnimationPlayer = $Animator2
@export_group("Config")
@export var animation_speed_base := 1.0
@export var animation_speed_scale := 2.0
@export var p_speed_max := 7
@export var p_time_gain := 7
@export var p_time_loss := 7
@export var p_time_lock := 7
@export var max_velocity_falling := (4.3125 * 60)
@export var max_velocity_walking := (1.5 * 60)
@export var max_velocity_running := (2.5 * 60)
@export var max_velocity_dashing := (3.5 * 60)
@export var acceleration := (0.0546875 * 60)
@export var deceleration_stop := (0.0546875 * 60)
@export var deceleration_skid := (0.125 * 60)
@export var gravity := 0.3125 * 60
@export var gravity_ab := 0.0625 * 60
@export_group("Variables")
@export var p_speed := 0
@export var p_timer := 0
var _direction : float
func _process(delta: float) -> void:
_direction = Input.get_axis("ui_left", "ui_right")
print(_direction)
func _physics_process(delta: float) -> void:
var direction = _direction
if direction == 0: velocity.x = move_toward(velocity.x, 0, deceleration_stop * get_time_scale(delta))
else:
if direction > 0:
if velocity.x >= 0: velocity.x = move_toward(velocity.x, +get_current_x_velocity(), acceleration * get_time_scale(delta))
else: velocity.x = move_toward(velocity.x, 0, deceleration_skid * get_time_scale(delta))
if direction < 0:
if velocity.x <= 0: velocity.x = move_toward(velocity.x, -get_current_x_velocity(), acceleration * get_time_scale(delta))
else: velocity.x = move_toward(velocity.x, 0, deceleration_skid * get_time_scale(delta))
velocity.y = move_toward(velocity.y, max_velocity_falling, get_current_gravity() * get_time_scale(delta))
move_and_slide()
position.x = maxf(position.x, 24)
func get_current_x_velocity()->float:
return max_velocity_walking
func get_current_gravity ()->float:
if Input.is_action_pressed("ui_accept") || Input.is_action_pressed("ui_cancel"):
return gravity_ab
return gravity
func get_time_scale(delta:float)->float:
return delta/(1.0/60.0)
Note this is gdscript.