Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no way to set one-way collision directions #12791

Closed
leoddd opened this issue Nov 9, 2017 · 11 comments
Closed

There is no way to set one-way collision directions #12791

leoddd opened this issue Nov 9, 2017 · 11 comments
Assignees
Milestone

Comments

@leoddd
Copy link
Contributor

leoddd commented Nov 9, 2017

Operating system or device, Godot version, GPU Model and driver (if graphics related):
Windows 10 (x64), Godot 3 Alpha 2

Issue description:
In Godot 2.x, one-way collision was exposed in the form of a direction vector and a number for the maximum depth inside the body, which was great and fully customizable.
In Godot 3, all that is replaced with a boolean checkbox. Enabling it will make the shape only collide from the top, with no way to change this, at least none are exposed in the editor or outlined in any documentation for code. It always points up.

When the body rotates then this direction changes with the rotation just fine, meaning it can handle rotating the direction it's solid from.
Is there a reason the directional setting was removed?

As an aside, the documentation for CollisionShape2D's one_way_collision member states that you can somehow choose top or bottom, but it is always only solid from the top.
Which, by the way, is strange because the giant arrow that is drawn in the editor window always points down.

Steps to reproduce:

  1. Create any CollisionShape2D, CollisionPolygon2D or TileSet tile with One Way Collision enabled.
  2. Struggle to find a way to change the direction it is solid from.
@reduz
Copy link
Member

reduz commented Nov 10, 2017 via email

@leoddd
Copy link
Contributor Author

leoddd commented Nov 10, 2017

Would performance take a hit from re-adding a way to set the direction for each shape?

I'd mostly prefer not to have to rotate everything because when I programmatically create polygons, having to rotate the location of every vertex each time just to counteract the rotation I'll have to give the shape to set the one-way direction is time consuming. And having to misalign the collision objects in Tiled on purpose to account for the rotation that will be applied, unless I want to actually rewrite the importer for this, isn't ideal either.

Which I think is a bit of a heavy expectation for something that used to be possible pretty easily? I suppose it depends on how heavy on the processing implementing this would be, but given that one-way directions are generally not even enabled on the majority of shapes I can't imagine this being a terrible processing sink.
But that's coming from someone with very little clue of how this is actually implemented, if there's solid reasons that speak against this then I'll have to accept that.

@reduz
Copy link
Member

reduz commented Nov 10, 2017 via email

@leoddd
Copy link
Contributor Author

leoddd commented Nov 10, 2017

I can give it a try, sure. Can't promise I'll have results because I've never looked deeper than a method or two into the source and am not terribly well versed in the language, but I understand that there's more important things with the release of 3.0 approaching (missing features, bugs, what have you).

If anyone else thinks they can handle it then don't let me trying to look into it deter you though!

@eon-s
Copy link
Contributor

eon-s commented Nov 10, 2017

Rotating and/or having more than one (rotated) shape and disabling now should work, I liked the old way though, it was easy to modify on the script side.

@fossegutten
Copy link
Contributor

rotating a tile with one way collision in tilemap does not rotate the one way collision in 3.0.2. Would be nice to have the option of choosing direction, maybe even multiple directions? E.g. collision in vertical movement, but no collision in horizontal movement

@eon-s
Copy link
Contributor

eon-s commented May 9, 2018

@fossegutten there is already an issue opened about tilemaps and 1 side (which has many problems), multiple directions can be achieved with multiple shapes, won't work on tilemap, though.

@henriiquecampos
Copy link
Contributor

henriiquecampos commented May 30, 2018

Hey guys, I'm testing the rotation for the shape to set the one_way_collision direction and even tho I'm rotating the CollisionShape / CollisionPolygon the one_way_collision is always Vector2(0, -1)

@akien-mga
Copy link
Member

It's currently the way it is for simplicity, you can rotate the shape though, as this option is now per shape.

@reduz It doesn't seem to work though, as #18493 and #20204 confirm that one-way collision shapes don't work properly when rotated.

@Daniel-The-Fox
Copy link

Hi there, 👋🏻

I'm new to Godot and I'm using version 4.1.2 and I stumbled upon this discussion here while searching for a description on how to use the "One Way Collision" checkbox in the Inspector. Unfortunately, the docs don't describe that in detail, but I'll open a PR to add 1-2 describing sentences in the docs in parallel in a sec... 📝

Apart from that, I believe that the big red arrow in the 2D View Editor is pointing in the wrong direction and should be inverted. 🤔

When I activate the "One Way Collision" checkbox on a CollisionShape2D the big red arrow points downwards in the 2D View Editor (rotation of shape is 0°). If I rotate the CollisionShape2D by 180°, the big red arrow then shows upwards. So, default seems to be pointing downwards. Ok so far...

The issue is that when I use this CollisionShape2D in a GD script to disable the collision shape for a certain amount of time (collision shape is the edge of the grass on the ground, enemy is getting spawned inside/behind grass before flying upwards and then the collision shape is enabled again), the enemy velocity bounce is exactly inverted from what I would expect, meaning to the opposite direction in which the big red arrow shows in the 2D View Editor... 😢 🤔

Could you please have a look into this as it's quite confusing for new Godot users like me... 😆 😞

@AThousandShips
Copy link
Member

Please open an issue or ask in some of the other community channels, this has been closed for five years and isn't the place to ask this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants