how to collide the right way?

hi

I have made a city where a player can run through. At the moment, my player runs though buildings and I don’t know how to make him not to do so.

my player-prefab has a rigidbody (without gravity), and a box-collider (Is Trigger == true) … those are needed for my further game-logic.

when i now make a other gameObject with a collider, my player runs through that. how can I make him stop running through buildungs?

Hi,

Your player should have at least one collider which not is a trigger.

1 Like

oh… so you mean two colliders on one gameobject(?) … hmm… i’ll try this out… but how is it with the rigidbody? i need it because the joystick i use needs it to move my player around… when I untrigger the collider and it collides, the player falls on the ground or flies around… :confused:

No, the player and the city must have a collider (not a trigger) one for the character, and one (orr maybe more) for the city. It doesn’t matter if you have triggers associated with your character. When i say the “city” i mean all of its parts, these might be represented as one big mesh, or maybe a bunch of meshes (it depends on the hierarchy used in your 3D modelling software). You can generate a collider for your entire imported 3D model (assuming your entire city has been imported as one object) by clicking “generate colliders” in the model import settings.
https://docs.unity3d.com/Manual/FBXImporter-Model.html

yes, I understand that and all of my buildings have mesh-colliders. the problem is, that I need to know if the player collides with some other certain objects… therefor the player has a collder with trigger=true. the player also needs rigidbody.

now this constellation does not work with walls… my player runs throught buildings…
when i unset the trigger on the player-collider, the player can not run through walls, but when he collides, he starts acting wierd… he flies around or he falls & stuff …

so i need a solution where i can identify, when my player collides, but the player does not run through the collider.

Are you using a rigidbody or a character controller for your character?