Sorry if my question is answered before,
I am trying to create game like oxenfree in AC with 3d characters and 2d background .
So i needed 2d collider on 3d model and distance the model from the collider in different z of the background to avoid sorting issue
However when i tried it with tin pot and start the game the model and the collider sticked together again in the same z.
So my question is basically are there any tutorial about how to set up my character whether i should use 2d/3d character in character wizard and how should i set up collider and animation for that.
Comments
I am quite new to programming, so i am trying to understand your 3d approach.
I am not sure why or how rely on 3d set up will eventually solve z fighting,
It seems to me even i am adding 3d colliders to the unwalkable area in 2d scene on x,y plane . i wouldnt be able to create a fake sense the depth like 2d will, such as rendering the character place on larger y value at the back of smaller y value character(like Sorting Map does).Adding collider to entire model will just collide them all or z fighting each other.
As you mentioned it can be a unity problem not ac, in such case i will just render my 3d model into 2d sprite sheet.
I apologize if i am asking a dumb question because of my limited programming knowledge.
Edit: Silly me, right after posting this I figured it out. I'll leave this here in case anyone else has a similar problem in the future -solution below.
Original issue:I tried using the script above for sorting layers correctly for 3D character with a 2D background but there's one issue - I need my character to be rendered by an orthographic camera (so we don't get a perspective view of him when he moves to the sides) but I want the sprites in the background to be rendered by a perspective camera (for some effects)
Issue is, as soon as I apply the script above, it forces my character camera to a become perspective as well, and basically overrides the orthographic setting. Removing the script fixes the issue (but I still need the sorting layers to work of course)
I don't know how to code, but going through the script I assume it's copying the settings from another camera to the one with the script, which means it's also copying the perspective setting and applying it to this, correct? Any way to avoid this? Thanks!
Solution: Just remove the line "ownCamera.projectionMatrix = Camera.main.projectionMatrix;" from the code, and it should work perfectly. I'm not sure if this will cause different issues down the line though, but as of now everything seems correct.
Edit 2: Ran into an issue due to this edit pretty soon lol, but fortunately I've got a solution to that as well.
Removing the line above will make the objects on your "foreground" layer move at a different speed than your background sprites (so the two layers on either side of your character) giving it an unplanned parallax effect. To avoid this, create a duplicate of the script provided by Chris, and in this do not remove the line above, and add this unedited script only to the foreground camera (and only add the edited script without the line above to the player)