1
\$\begingroup\$

I want to have a 3d game object (player) who converts to ghost.

That means that the user must not collide with other players, but must not pass walls, trees, and must take care about terrain height levels (I mean, I can't put it as kinematic and remove the collider because the Vector3.MoveTowards which moves the player will ignore the height dimension and will pass the mountains, etc)

My was thinking about tagging the players and in some way try to skip the collider between them.

Any idea? Thanks

\$\endgroup\$
0

2 Answers 2

3
\$\begingroup\$

You can implement this using Layers.

  • Create two new layers "Ghost" and "Player".

  • Assign the "Ghost" layer to the players who are ghosts.

  • Assign the "Player" layer to the players who are not ghosts and to any other objects which are not supposed to interact with ghost players.

  • Keep anything which is supposed to interact with players and ghosts equally (like walls, trees and terrain) on the already existing "Default" layer.

  • Set the layer collision matrix under Edit -> Project Settings -> Physics -> Physics Manager as follows:

    • "Ghost" collides with "Default" but not with "Player" and "Ghost" (unless, of course, you want ghosts to interact with each other)
    • "Player" collides with "Default" and "Player" but not with "Ghost"
\$\endgroup\$
0
\$\begingroup\$

You can make use of the Unity collision layer. With this you can tag which layers can collide with which. In the edit you can select that players can not collide with ghosts by untagging the layer for it. You can add a layer for let's say environment_objects for doors and such with which they collide. Applying the layer to the gameobjects by selecting it will activate the given settings to the layer. I think this will achieve the results you desire.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .