0 votes

Is it possible to set an area2d as static or something so you can't enter it? Thanks

Godot version 3.2.1
in Engine by (450 points)

don't think so, why not just put a static body on top of it? what exactly is the context here?

I am making a top down game with a z axis I programmed in, and so if there is a platform, you need to be able to collide with it if you are not above it, however you need to be able to go into it if you are above it, it’s complicated. Luckily I figured it out and now have a working z axis!

just for the rest of people in that case all you need to do is make the platform a one way collision, you don't need any area2d for that.

You can't use a one way collision, as direction actually has nothing to do with it, in fact you need to be able to collide with it from all directions, but also pass through it from all directions. Remember, this is a top down 2d game that I programmed in a z axis for. What I had to do was make all platforms and entities an area. The entities had a ray cast that points in the direction they are moving, and if it collides with a platforms, I make two arrays, one for the entity, one for the platform with every pixel from their base to their top on the z axis by taking their z position through their z position plus their height in pixels, then I intersect the arrays, and if one pixel overlaps and is the same between arrays, they should collide and the entity can't move forward because it is not over or under the platform, but if the arrays don't overlap, the entity can move forward, because even though the entities collider would be colliding with the boxes collider, it would be above or below it. Then from there, you have to see if the entity is above or below it, if it is below, it can pass through unless it jumps up to the height of the base of the platform, in which case it must collide because its head would on the top of the platform, but if it is above, it's z floor, or the distance it falls to must be equal to the platforms base. Sorry that was so long lol, I kind of just started typing and kept going. If you did figure out a way to use one direction platforms for this though, that would be amazing.

1 Answer

+1 vote

If you want to prevent a body to enter a region you need to use an StaticBody2D node if the shape is static, or a KinematicBody2D, RigidBody2D if you want the node to move. This will prevent other physics nodes of entering the region.

by (36 points)

Yeah I know but for what I was doing I needed areas, not bodies. Thanks for answering though.

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.