Skip to content

CharacterBody2D scale error #102613

Open
Open
@oijqws

Description

Tested versions

v4.4.beta3.official [06acfcc]

System information

win 10 godot 4.4 beta3 AMD Radeon(TM) Graphics

Issue description

if scale then play animated_sprite, scale would work as scale.x *=-1

	animation = "idle"
	var direction := Input.get_axis("ui_left", "ui_right")

	if Input.is_action_just_pressed("ui_left"):
		scale.x =-1

	if Input.is_action_just_pressed("ui_right"):
		scale.x = 1


			
	animated_sprite_2d.play(animation)

Steps to reproduce

code above

Minimal reproduction project (MRP)

extends CharacterBody2D


const SPEED = 300.0
const JUMP_VELOCITY = -950.0
@onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D

var animation = ""
var new_dir = 1
func _physics_process(delta: float) -> void:
	# Add the gravity.
	if not is_on_floor():
		velocity += get_gravity() * delta * 2

	# Handle jump.
	if Input.is_action_just_pressed("ui_accept") and is_on_floor():
		velocity.y = JUMP_VELOCITY

	# Get the input direction and handle the movement/deceleration.
	# As good practice, you should replace UI actions with custom gameplay actions.
	animation = "idle"
	var direction := Input.get_axis("ui_left", "ui_right")

	if Input.is_action_just_pressed("ui_left"):
		scale.x =-1

	if Input.is_action_just_pressed("ui_right"):
		scale.x = 1


			
	animated_sprite_2d.play(animation)
	move_and_slide()

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions