Godot Version
4.6
Question
My player sprite broke when i replaced the placeholder with the actual sprite.
ive been using an online tutorial to help create a base for a 2d game, “Make a 2D Action & Adventure RPG in Godot 4” by Micheal Games on youtube. ive been using the free sprites he provides, and have decided to replace them with my own, starting with the player. it looks normal in the viewport, but when i playtest the game, it gets super pixelated and distorts when it moves, not slightly either, like it stretches across the screen and doesnt go back to normal

stuff like this keeps happening, this sprite was sized up and is shrinking, the sprite i want to use is resized to 0.1 and stretches back to its original x size
main player code
class_name Player extends CharacterBody2D
var cardinal_direction : Vector2 = Vector2.DOWN
var direction : Vector2 = Vector2.ZERO
@onready var animation_player: AnimationPlayer = $AnimationPlayer
@onready var sprite: Sprite2D = $Sprite2D
@onready var state_machine: PlayerStateMachine = $StateMachine
# Called when the node enters the scene tree for the first time.
func _ready():
state_machine.Initialise(self)
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
##direction.x = Input.get_action_strength("right") - Input.get_action_strength("left")
##direction.y = Input.get_action_strength("down") - Input.get_action_strength("up")
direction = Vector2(
Input.get_axis("left", "right"),
Input.get_axis("up", "down"),
).normalized()
pass
func _physics_process( delta ):
move_and_slide()
func SetDirection() -> bool:
var new_dir : Vector2 = cardinal_direction
if direction == Vector2.ZERO:
return false
if direction.y == 0:
new_dir = Vector2.LEFT if direction.x < 0 else Vector2.RIGHT
elif direction.x == 0:
new_dir = Vector2.UP if direction.y < 0 else Vector2.DOWN
if new_dir == cardinal_direction:
return false
cardinal_direction = new_dir
sprite.scale.x = -1 if cardinal_direction == Vector2.LEFT else 1
return true
func UpdateAnimation( state : String ) -> void:
animation_player.play( state + "_" + AnimDirection() )
pass
func AnimDirection() -> String:
if cardinal_direction == Vector2.DOWN:
return "down"
elif cardinal_direction == Vector2.UP:
return "up"
else:
return "side"
player state machine
class_name PlayerStateMachine extends Node
var states : Array[ State ]
var prev_state : State
var current_state : State
# Called when the node enters the scene tree for the first time.
func _ready():
process_mode = Node.PROCESS_MODE_DISABLED
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process( delta ):
ChangeState( current_state.Process( delta ) )
pass
func _physics_process( delta ):
ChangeState( current_state.Physics( delta ) )
pass
func _unhandled_input(event: InputEvent) -> void:
ChangeState( current_state.HandleInput( event ) )
pass
func Initialise( _player : Player ) -> void:
states = []
for c in get_children():
if c is State:
states.append(c)
if states.size() > 0:
states[0].player = _player
ChangeState( states[0])
process_mode = Node.PROCESS_MODE_INHERIT
func ChangeState( new_state : State ) -> void:
if new_state == null || new_state == current_state:
return
if current_state:
current_state.Exit()
prev_state = current_state
current_state = new_state
current_state.Enter()
state_walk
class_name State_Walk extends State
@export var move_speed : float = 100.0
@onready var idle: State_Idle = $"../Idle"
##what happens when player enters state?
func Enter() -> void:
player.UpdateAnimation("walk")
pass
##what happens when player exits state?
func Exit() -> void:
pass
##what happens during _process update in this state?
func Process( _delta : float ) -> State:
if player.direction == Vector2.ZERO:
return idle
player.velocity = player.direction * move_speed
if player.SetDirection():
player.UpdateAnimation("walk")
return null
##what happens during the _physics_process update in this state?
func Physics( _delta : float ) -> State:
return null
##what happens with input events in this state?
func HandleInput( _event: InputEvent ) -> State:
return null
state_idle
class_name State_Idle extends State
@onready var walk: Node = $"../Walk"
##what happens when player enters state?
func Enter() -> void:
player.UpdateAnimation("idle")
pass
##what happens when player exits state?
func Exit() -> void:
pass
##what happens during _process update in this state?
func Process( _delta : float ) -> State:
if player.direction != Vector2.ZERO:
return walk
player.velocity = Vector2.ZERO
return null
##what happens during the _physics_process update in this state?
func Physics( _delta : float ) -> State:
return null
##what happens with input events in this state?
func HandleInput( _event: InputEvent ) -> State:
return null
im not sure what exactly to give yalls to mkaeit easier to figure out, so i thought to show everythin, none of the code is mine as stated, its all word for word from the tutorial i mentioned
for the record, the entire thing worked perfectly fine on the example sprite sheet attached to the tutorial.
i think its really important to mention i am an absolute noob at coding, so if anyones got any solution ideas, could you explain them in as much detail as possible? such as where to approximately insert a line of code, for example. ![]()


