Forum rules - please read before posting.

Character ignores axis movement when gamecamera's rotation is not 90/-90

I have created a new character and am using Sprites Unity for animation setup. When i create any new scene and put the character in, if the camera has a Y rotation close to 0 or 180 the character simply refuses to move on the horizontal axis or using a/d. This gradually becomes better as i rotate the camera closer to 90 or -90, and at these two values it moves perfectly in all four directions (however with this rotation the sprite is not facing the camera correctly, like it is slightly skewed to the left at about 20 degrees (at 0 and 180 camera Y rotation it looks perfect).

It's all very strange to me, and i don't have the same issue with the demo Robot character using mecanim - i also tried just copying every aspect of the Robot character, only with the sprite as a child object, but as soon as i change the animation setup to Sprites it messes up.

Does anyone have any idea what is going wrong here?

Comments

  • edited July 2020

    Welcome to the community, @darknath. What are your AC and Unity versions?

    Despite using sprites for your characters, are you still - in effect- making a 3D game? Or are you looking to limit the character's motion to 2D?

    As this is a visual problem, can you can share some screenshots of what exactly is going on (scene and game windows), as well as your Settings Manager? That will help me understand the situation.

    If you're using Direct movement, and the Settings Manager's Turning type is set to Relative To Camera, then the "horizontal axis" will be in camera space, not world-space. Though, there shouldn't be a difference in behaviour based on what graphics the character uses.

    Be sure to assign your character's "Sprite child" field. If your scene is in 3D, you'll also have an additional Rotate sprite to field in their Inspector that may help to fix the rotation issue. Also make sure that Turn root object in 3D? is checked.

  • Hey Chris, thank you very much for answering.
    I am on Unity 2019.3.6f1 currently with AC 1.71.1

    Yes it's a 3d game with a character that is essentially 2D - character's motion is going to be either 4 directional in a 3d perspective.

    So here are 2 videos of what is going on (gamecamera is selected to show settings in inspector on the right):

    Video 1: Showing the character moving into the screen, but when i try to move left or right on the keyboard or controller the character is frozen in place, yet still playing the correct animation. The sprite is facing the camera directly here.
    https://youtu.be/2I_BWWjMyOY

    Video 2: Showing the character in the same spot in the world, but the camera has been moved to the right of the previous location and rotated to face spawnpoint. Here walking in any direction is fine, but the sprite seems skewered and looking to the left.
    https://youtu.be/MIMOpsW_sY0

    Here are screenshots of the settings window and the player component to show the settings, that match what you said, except for Turn root object in 3D (i have tried with this on also, which didn't help except the sprite gets "skewed" to the left or right when walking in those directions).


  • Update: Tried updating to AC 1.71.7 - issue still persists

  • Keep the "Turn root object in 3D?" option on. It sounds like there's an issue with the sprite child not being able to turn correctly.

    What's your Player's hierarchy like? Are you using a 2D skeleton? Also be sure to have him rely on 3D physics components, not 2D ones, if the scene itself is in 3D.

    Try dropping in the 2D Demo Player, Brain2D, into the scene instead. Replace his 2D Rigidbody/Collider with a single Character Controller and re-size it to suit - does he behave correctly?

  • Alright, dropping the Brain2D prefab in helped me to understand where the problem lied. The movement was somehow limited because it had apply root motion enabled - why camera placement was influencing this i have no idea, but thanks for helping me through to figure it out.

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.