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

Make interactions be blocked by Environment safely #114

Merged
merged 3 commits into from
Mar 13, 2024

Conversation

FailSpy
Copy link
Contributor

@FailSpy FailSpy commented Mar 12, 2024

This one's pretty self-explanatory. Resolves #110

@FailSpy
Copy link
Contributor Author

FailSpy commented Mar 12, 2024

I was going to add an exported check to the Player controller to adjust this, but I realized it's probably better to let devs adjust the layering system themselves to suit their needs. I think this is good for a default, and if devs want something else then it's very simple to change back or make work in other ways without being too prescriptive.

@Phazorknight
Copy link
Owner

Phazorknight commented Mar 12, 2024

Not sure if this is needed?

Issue #110 is caused by the walls not set on collision layer 2. Setting them to layer 2 fixes it, so I'd personally not change any existing layer structures on the player interaction component, especially since it would force users to update the collision layers on all their interactive objects.

But I'd be happy to hear of any other advantages that I might not be aware of.

@FailSpy
Copy link
Contributor Author

FailSpy commented Mar 12, 2024

As it is right now, in the Project Settings of the Cogito Godot project is Layer 1 is defined as "Environment", and Layer 2 is defined as "Interactables". To me it seems conflicting to have to make all your environment pieces "Interactables" to be physically blocking interactions.

So I don't see that it would be a good idea to have users be moving all of their environment that is not literally Interactable onto the Interactables layer just to get this feature out of the environment.

All I've done in the PR is move the player on to its own layer so that way the interaction raycast can't hit it, and include Environment as a collision layer for the raycast to have environment block interactions.

Unless this layer setup is no longer of interest, at which point the layer names should probably be changed. Though personally, I would prefer environmental pieces on the default layer 1 to be blocking interactions.

Also by not encouraging the separation of these layers, then you would have no way to discern Interactables vs Environment purely via Raycast if you did want interactions to work through walls, you have to do the raycast, then check if what it hit is in the group.

@Phazorknight
Copy link
Owner

That makes sense!
Having the environment block by default would definitely be great.
Let me take a closer look at the PR.

@Phazorknight
Copy link
Owner

Hey @FailSpy , when I open this on my end, playtesting the project makes my resolution all pixely, no matte which one I select from the options + the temp UI scaling slider is gone.

Could you take a look to undo any changes to those in this PR?

I'd try to cherrypick, but with the update layersettings I'd like to keep the project.godot file from this PR.

@FailSpy
Copy link
Contributor Author

FailSpy commented Mar 13, 2024

Oh those changes weren't included cause that PR wasn't merged when I started the interactions-fix branch. Will update the branch and that should fix it!

@FailSpy
Copy link
Contributor Author

FailSpy commented Mar 13, 2024

@Phazorknight give it a try now?

@FailSpy
Copy link
Contributor Author

FailSpy commented Mar 13, 2024

Oh wait, hold off. Found a major issue with the layering setup: bunch of stuff now doesn't collide with the player. Attempting a workaround that minimizes breakage of other people's existing work...

@FailSpy FailSpy marked this pull request as draft March 13, 2024 17:19
@FailSpy FailSpy marked this pull request as ready for review March 13, 2024 17:53
@FailSpy
Copy link
Contributor Author

FailSpy commented Mar 13, 2024

@Phazorknight
Okay, so I've gotten rid of the player layer to be minimally conflicting with existing projects as it'd be a nightmare. Encountered all sorts of interesting bugs. As nice as it would be to have a separate player layer, I feel it's a bit much to do right now, so this is the absolute minimum set of changes to accomplish this PR's goal

  • Environment layer is included in Interaction raycast
  • Player class when setting up the Player Interaction Component manually configures the interaction raycast to exclude the Player (and thusly, its colliders) specifically, that way the player can be on any layer, and the interaction raycast will ignore it.

EDIT: Force-pushes cleans up commits into one commit, considering the original commit for this branch was basically completely undone.

@FailSpy FailSpy changed the title Create player layer; make interactions be blocked by Environment Make interactions be blocked by Environment safely Mar 13, 2024
@FailSpy
Copy link
Contributor Author

FailSpy commented Mar 13, 2024

@Phazorknight Okay, properly ready now to be pulled in. Give it a shot, see how it goes for you.

Copy link
Owner

@Phazorknight Phazorknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seemed good on my end! Gonna approve.

Thank you so much for this!

@Phazorknight Phazorknight merged commit 05bcaf0 into Phazorknight:main Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interact with object through walls
2 participants