Hi folks. Sorry if this has been addressed elsewhere, but I can't find an answer.
I have a 2D project (2D camera + Unity2D in camera settings). Because it's top down, I just want to rotate the character sprites instead of having separate animations for each movement direction.
Is this possible to do in Adventure Creator without extra scripts? I made a script that will rotate the sprite based on movement direction, but facing a hotspot after movement doesn't work with that. Hopefully I'm just missing a setting somewhere!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Welcome to the community, @GongylusGames.
Good question. If a character is set to rotate, they'll do so around the Y-axis.
AC's 2D camera mode works in the X/Y plane. You'd either need to rely on a script to rotate the character's sprite as a child object, independent of AC, or switch to 3D and just use sprites for your 3D character graphics.
A 3D game can use a true top-down camera in the X/Z plane, and characters will rotate correctly by default. You can use an Orthographic camera, and sprites for character graphics/animation, to have it appear 2D.
It would, however, mean that your game is technically 3D - so you'd need a 3D NavMesh, 3D Colliders for your Hotspots etc. No big issues in particular - just something to be aware of.
If you wanted to stick to purely 2D, a custom script would be necessary. If you'd like to share the script you made, along with some screenshots of the issue it causes, I'll see if I can spot what's wrong.
Sorry for slow reply. This is for Brackeys Game Jam so been working flat out!
This is the code I'm use to brute force the z rotation to the move direction. One thing I noticed is that AC automatically wants to turn the sprite to face either left or right at 90 degrees. And I'm having trouble trying to get a direction to look at with either OnSetHeadTurnTarget or OnSetLookDirection. I'm guessing this is because it's not designed to work in this axis? Not sure. If I were to start from scratch, I'd probably just make my own movement controller. If there is an simple way I can get the character to face the hotspot after movement I'd be over the moon!
Your script only reads the character's movement direction - which isn't 100% always the direction they're facing, and won't be set when standing still.
What you can do, however, is check Turn root object in 3D? in the Player's Inspector. What this does is cause the root to rotate around the Y axis, as though it were in a 3D game.
What your script can then do is read the root transform's forward direction, and swap the Y and Z values to get a direction in the X/Y plane you can apply to your sprite.
You'll also want to set your Settings Manager's Vertical movement factor to 1, to prevent the Y-axis motion being scaled, which is used by "normal" AC 2D games to give the illusion of depth.
Oh interesting! Thank you! I'll give it a go!
You're a genius. All it took was this in LateUpdate. Thank you!