Help with testmove()

Godot Version

4.6.1

Question

I’m running the code

if test_move(leftwj.transform,Vector2(10,0)):
    print("wj")

(leftwj is a hitbox under my character’s scene)

but this isn’t printing anything and I have no clue why and I’ve been stuck on this for an ungodly amount of time please help

Not expert but looks your condition is not executed to do print

1 Like

From the documentation of PhysicsBody2D::test_move() method, we can see this:

Returns true if a collision would stop the body from moving along the whole path.

Your print() statement is after checking if the test_move() call is true.
This implies that the movement along the vector you provided doesn’t collide with anything, so your print statement is never called.

1 Like

but like, it does

So i ran the code in a print statement and its returning false

Ok so I’ve placed blocks at 0,0 and its returning true because thats where the character body 2d is in its scene so how do i make it check for the hitbox location in the correct scene

It’s hard to understand what you’re trying to do without seeing how your scene is structured and what you’re trying to collide.
My immediate thought is that you should try the leftwj.global_transform instead of local transform. But it’s just a wild guess.