Forum rules - please read before posting.

Character inclination

In the 2.5D game, with fixed cameras, would not it be possible to avoid the inclination of the character when it is too close to the edges?

Comments

  • Sorry, what inclination?  Please illustrate with screenshots if you can, I need more detail to understand.
  • I removed the mask sprite to see you better.

    image

    I have done several tests and I understand that the inclination of the character depends on the various parameters of the camera but above all by its height and rotation.
    The problem is that the walking area is very large and I am forced to lift up the camera a lot.
    I was able to achieve better results by working on the camera image but the character is always a little inclined.
    I think it depends on perspective and there is little to do.
    Am I wrong?

  • It is based on perspective - the pre-rendered and in-game camera must match, and as the image's camera isn't rotated downwards neither should the Unity camera.

    It may be a case of offsetting the perspective matrix of the Unity camera, something that can be done with the provided SetVanishingPoint function:

    Vector2 perspectiveOffset = new Vector2 (0f, -10f); // Downwards shift
    myCamera.perspectiveOffset = AC.AdvGame.SetVanishingPoint (myCamera, perspectiveOffset);


    Currently, the MainCamera will only copy the perspective offset if you're using a 2D camera - but I can look into amending that if you find that shifting perspective is what's necessary.
  • One thing I can tell you is that when the camera is high and rotated downwards the inclination increases (at least in the case of my background).
    It may be that if you look for the best distance, height, rotation, field view of the camera you can improve this condition.
    However I do not want to waste your time, I could be wrong, I come from Wintermute and Unity is a new world for me.
  • edited September 2017
    One thing I can tell you is that when the camera is high and rotated downwards the inclination increases (at least in the case of my background).

    If by inclination, you mean the character becomes slanted, then yes that would be true.  My point about shifting the perspective is that you can keep the camera looking straight ahead (no downward rotation), you can still show more of the screen below it than above.
  • In v1.59b, the GameCamera 2.5D will be upgraded to allow for perspective offsetting - removing the need for custom code as above.  This may help with the inclination issue, as it will allow you to view "beyond" the camera's regular FOV without having to rotate it downwards.
  • edited September 2017
    Will it just apply to the 2.5D or even 2D camera? 
    I'm doing tests with an identical 2D + Screen Space + Unity Navigation scene with Orthographic or Perspective camera. Even in this case, since the scene is seen a little from the top, in the Perspective mode there is the inclination of the character.
    In this regard I would like to ask you a question without opening a new thread.
    I have noticed that with the camera in orthographic mode when it is very rotated downwards the background is distorted. Is there a maximum known limit to be observed to avoid distorsions? So for framing from above I need to rotate the background together with the camera?
  • The 2D camera already has this feature - when using Perspective projection, the Offset values in the GameCamera2D camera cause the same shift.

    2D cameras shouldn't be rotated downward, as Unity's own 2D view depends on the camera being straight-on.  You haven't provided any illustration of the distortion you're observing, but it will only increase with the rotation.

    The only background image you've shared shouldn't have any such rotation, because all vertical lines are completely vertical.  Only a perspective shift in the way I described above should be used.  If you're referring to a new background that does involve an angled camera, and you want to use the 2D camera, you could try using a custom script to rotate the character around the X-axis to fake the effect.  This may need to be done on a child object in between the root and the model/rig, or in LateUpdate.
  • edited September 2017
    2D cameras shouldn't be rotated downward

    I'm still studying all the various possibilities offered by your plugin.
    I've seen that in pure 2D, with Orthographic mode, Moving and Turning = Unity 2D and NavMesh2D, the rotation though minimal is impossible because it immediately offsets the path of the character.
    In Orthographic mode + Screen Space, I use the camera's rotation to match the NavMeshSegment with the background floor.

    image

    I have a bit of trouble building mesh with 3DS Max on a 2D image. I can create the background mesh to use for HotSpot (to match objects for which I can not use the collider box) but it's not very easy for the floor to be seen in perspective.
    Since in Perspective Projection I also need to rotate the background I was trying to figure out if I could use the Orthographic mode where the background does not distort by rotating the camera.
    But you are telling me that I should not rotate the camera in 2D so I will look for other solutions.

    If you're referring to a new background that does involve an angled camera

    Yes, it is, I tried another background that required a strong rotation of the camera.
    I had thought about the eventual rotation of the character and you confirm this.
    Thank you for your support and for your patience.


  • It doesn't seem right that you should have to give the background image a different rotation than the camera.  If you're relying on NavMesh segments and want to rotate the camera, I'd say you're better off with 2.5D mode.

    The next update will allow you to pan the camera which will hopefully solve the inclination error posted at the start of this thread.  I can PM you a WIP package to test with if you like.
  • No, I've probably explained badly.The rotation I make on the plane is the same as the camera and everything works well. I was trying the Orthographic mode just to avoid rotating the background.
    After all my tests I also think the best mode is the 2.5D but since I would like to use scrolling it seemed useless to choose this mode and then do not use the 2.5D camera but the 2D camera.
    Of course, without any hurry when you have a little time I would like to test the package.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.