0 votes

Hi. I am new to godot. But, I have searched a lot of internet and even thought I found why this error keep poping, i wasnt able to get it work. So here is what i am doing:

Firs, I have node Player in main scene,
in that i have the Sprite node and CollisionShape2d

Then, I have a script in the Player node. And I want to flip the image (Sprite) with the script.
So that looks like that:

(I have moving the player and sprite in the script too, but this is not important)

extends KinematicBody2D

var score : int = 0

var speed : int = 200
var jumpForce : int = 600
var gravity : int = 800

var vel : Vector2 = Vector2()

onready var sprite : Sprite = get_node("Sprite")



 func _physics_process(delta):

    vel.x = 0

    if Input.is_action_pressed("move_left"):
        vel.x -= speed
    if Input.is_action_pressed("move_right"):
        vel.x += speed

    vel = move_and_slide(vel, Vector2.UP)

    if vel.x < 0:
        sprite.flip.h = true
    elif vel.x > 0:
        sprite.flip.h = false
Godot version godot 3.5 stable win
in Engine by (12 points)

1 Answer

0 votes

Sprite doesn't have a flip property. It has flip_h and a flip_v properties. You can see them in the Inspector, or in the Sprite documentation:

https://docs.godotengine.org/en/stable/classes/class_sprite.html

by (21,714 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.