#The Collision doesn't work

6 messages · Page 1 of 1 (latest)

candid berry
#

Hello I'm new to Godot (I Downloaded it a week ago) and I've been making progress on my little game I made on Scratch (The website). Recently I had a problem where the player collider is clipping though the Collider2D node and I don't know why. (Also I tried RayCast2D, so if anyone can give me another way on how I can use it for this problem that would be appreciated).
I'm going to post a video and pictures of what the problem is in a little bit just to give you an understanding of what I'm talking about (and the code to)

#

Here is the video I’m taking about

#

This is the Raycasting Code

extends RayCast2D

func _ready():
pass # Replace with function body.

func _process(delta):
if is_colliding():
print("Collision!")

#

(I'm about to go to sleep, ALL HELP WOULD BE APPRECIATED

#

extends CharacterBody2D

var speed = 300

func _process(delta: float) -> void:

var x_axis = Input.get_axis("ui_left", "ui_right")
var y_axis = Input.get_axis("ui_up", "ui_down")
var input := Vector2(x_axis, y_axis)

position += input * speed * delta

if input == Vector2(1,0):
    $AnimatedSprite2D.play("Move")
    $AnimatedSprite2D.flip_h = true
if input == Vector2(-1,0):
    $AnimatedSprite2D.play("Move")
    $AnimatedSprite2D.flip_h = false
if input == Vector2(0,-1):
    $AnimatedSprite2D.play("Move")
if input == Vector2(0,1):
    $AnimatedSprite2D.play("Move")
    
if input == Vector2(0,0):
    $AnimatedSprite2D.play("Idle")
move_and_slide()