Invisible walls as in Project zomboid

Hello to all.
How can i do this in Unity?

I found this tutorial, maybe this is what I need.
However, I did not understand what should be in “OnTriggerEnter”? :eyes:
How can I make my character be the trigger?

Also, should I make each floor from separate walls or can I divide the entire wall of the house into different parts?
Thanks

I have not watched the video, but I can almost guarantee the answer you are looking for is use as many colliders as you need.

In my FPS I have a collider for movement, a collider for enemy attacks, a collider for item interactions, and a ray for footing.

It’s really okay to load it up so long as you are making sure to limit what they interact with in your project settings.

And as for triggers, think of them as being solely for logic such as switches or toggles for enemy AI.

If it’s physics based, don’t do a trigger.

As for invisible walls, just do a cube then delete the mesh components.

Maybe add a physics material with 0 bounce and 0 friction.

There are a lot of different objects that might register OnTriggerEnter with a trigger collider. If you want to write code that only responds to a specific object (like your player character) then you just have to identify the object. One easy way is to use tags. You could give the player object a tag called “Player”. Then in your OnTriggerEnter you can use CompareTag to see if the object’s tag matches. There is an example in the manual:
https://docs.unity3d.com/ScriptReference/Component.CompareTag.html

First of all, thanks a lot for your reply and Info!

Honestly, I took the script from this video (well, or another video on his channel …) and I managed to use it. Unfortunately, I did not understand why I could not write If (gameObject.name == "Character") as an input trigger, but I wrote it like this and everything began to work: If (other.tag == "Player")

Now i have this task:

  1. Make it so that when I go up to the second floor, the lower floor becomes visible along with the ceiling, and all the upper floors are still transparent. Well, I think you understand my idea.

  2. Also, I would like not the whole country to disappear entirely, but a small strip remained at the bottom and also in the corners. I’ll attach a picture.

  3. The script does not work correctly, because I can hit the wall and one part of the character climbs over the texture of the wall and the trigger is falsely triggered. How can i fix this?

And of course I am looking for the most optimal solutions. After all, I want to make a whole city, not a couple of three houses️

II appreciate any help and I will be glad if you can tell me something about at least one of these points.
Have a nice time!

7747017--974433--maxresdefault_1.jpg

Thanks, unfortunately I saw the answer only later:smile:

In principle, I already understood a little about triggers. Now I need to solve the problems that I wrote about above.

Any help would be welcome.:slight_smile:

I’d like to review this post with a new answer and another question related to this topic.

1. “See-trough Shader” from Unity asset store
Check out this paid asset on the asset store, it might provide a flexible and easy solution to this problem.

2. Lighting question
As seen in the tutorial video, upon deactivating the gameobjects, the room becomes sun-lit and behaves like an outdoor area (from a lighting perspective). This is a no-go for me, as this takes away the feeling of being in an indoor area.
How can a game object be cut/deactivated or excluded from the player camera, while still blocking light?