How do I make a sprite change once collided with a Kinematic2D Node?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By HarryCourt
:warning: Old Version Published before Godot 3 was released.

I don’t have any knowledge on doing so, can someone point me in the right direction?

Nothing in my scene has collisions (yet)

extends KinematicBody2D

#const GRAVITY = 200.0
const WALK_SPEED = 200

var velocity = Vector2()

func _fixed_process(delta):

    velocity.x += delta #* GRAVITY
    velocity.y += delta #* GRAVITY

    if (Input.is_action_pressed("ui_left")):
        velocity.x = -WALK_SPEED
    elif (Input.is_action_pressed("ui_right")):
        velocity.x =  WALK_SPEED
    elif (Input.is_action_pressed("ui_down")):
        velocity.y = WALK_SPEED
    elif (Input.is_action_pressed("ui_up")):
        velocity.y = -WALK_SPEED
    else:
        velocity.x = 0
        velocity.y = 0

    var motion = velocity * delta
    move(motion)

func _ready():
    set_fixed_process(true)

Please format your code properly.

timoschwarzer | 2017-07-23 09:31

:bust_in_silhouette: Reply From: eons

It can have many non-visible sprites as children of the body and turn them on and off when collisions or other things happens, or change the frame if is a spritesheet.

Since you are working with a kinematic body, remember that these are collision-aware when moving with move only, otherwise are regular kinematics (ignoring everything).

If you want passive detection, it may need some extra help, like using areas.