Usin a staticbody as a wall.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Syl


How to make my staticbody block the movement of my sprite please?

:bust_in_silhouette: Reply From: Bartosz

First your wall and your sprite needs to have collision shape attached. Your sprite needs to either KinematiceBody2D or RigidBody2D. To move kinematic body use move_and_collide or 'move_and_slide`. For rigid body use impluses or add forces.
Try looking on Godot examples of platformers to see how it can be done.

A simple sprite won’t work, as it is my player on the map, and movin quite well with keys (though I’d like to use the mouse)? Just need staticbodies to prevent enterin some spots.

Syl | 2018-03-25 19:33

read my answer I’ve clearly wrote that object you called in question “sprite” needs to be KinematicBody2D or RigidBody2D to be able to use physic engine for collision.

Bartosz | 2018-03-25 19:59

Ok, thxs for you! :slight_smile: Trouble is, my area2d for changin scene don’t detect the kinematic, and the rigid falls down…

Syl | 2018-03-25 20:07

Ok, done with the move_and_colllide. Cheers!

Syl | 2018-03-26 01:52