0 votes

I must be doing something wrong, because my player character just keeps going through the floor I made? This isn't the first time I've done this, and it's worked before! But for the life of me I can't figure out what's wrong this time.

Here is the setup I have:
(the floor is a door because it's what was on my desktop)
this is the player above a platform

There are the nodes:
here's the node's and stuff

the code looks like this:

extends KinematicBody2D

const UP = Vector2(0,-1)
const SPEED = 200
const GRAVITY = 10
const JUMP = 500

var motion = Vector2( )

func physicsprocess(delta):
motion.y += GRAVITY

if Input.is_action_pressed("move_left"):
    motion.x = -SPEED
elif Input.is_action_pressed("move_right"):
    motion.x = SPEED
else:
    motion.x = 0

move_and_slide(motion)

And this is what happens, and I can't figure out why
cool gif I made

It's probably something really simple, so like... please help.

asked Nov 19, 2019 in Engine by Seth (12 points)

1 Answer

0 votes

Area2D does not provide collision. It is for overlap detection and area influence. Your floor should be a StaticBody2D.

See here for details:
https://docs.godotengine.org/en/3.1/tutorials/physics/physics_introduction.html

answered Nov 19, 2019 by kidscancode (17,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 How to use this Q&A? before posting your first questions.