Character head poses wrong after loading a save

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
PeaceCat24
Posts: 6
Joined: Wed Nov 13, 2024 4:27 pm

Character head poses wrong after loading a save

Post by PeaceCat24 »

Hi, my game saves in the editor, but when I load the game, the character (a cat) is standing with her head/nose pointed straight down at the floor. She can run and jump, but she only lifts her head (it snaps up) when I move the camera around to the side and front of her face. Facing the front 180 degrees, her head is up and normal; when the camera is behind her, her head is down. Is there a solution? I had a position and animation saver on the main prefab for the character, but removed it, and it still happens. Thanks in advance.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Character head poses wrong after loading a save

Post by Tony Li »

Hi,

If you removed the savers and it still happens, then we know it's not the animators. This means it's probably nothing to do with the save system either, but with loading the scene with the cat in it. Can you try reloading the scene outside of the save system? For example, you could add a script like this to the scene. Then press F1 to test it.

Code: Select all

using UnityEngine;
using UnityEngine.SceneManagement;
public class ReloadSceneOnF1 : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F1))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }
    }
}
PeaceCat24
Posts: 6
Joined: Wed Nov 13, 2024 4:27 pm

Re: Character head poses wrong after loading a save

Post by PeaceCat24 »

Thanks for the response. Unfortunately when my partner saved a copy of the script, it apparently locked up the project and it cannot run or build. It's not in a scene, just saved as a script, he said.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Character head poses wrong after loading a save

Post by Tony Li »

Hmm, putting that script in the project shouldn't affect anything. Adding it to a GameObject, on the other hand, will make it so that when you play the scene and press F1 it reloads the scene.

Maybe something else was broken that was waiting for a recompile? Putting the script in the project would tell Unity to recompile all scripts.

Try going back in version control to an earlier version.
PeaceCat24
Posts: 6
Joined: Wed Nov 13, 2024 4:27 pm

Re: Character head poses wrong after loading a save

Post by PeaceCat24 »

Thanks for the reply. The error says "The name 'SceneManager' does not exist in the current context". When reopening the project, it opened in safe mode.
We use sectoring, rather than scenes, which may be why?
I don't understand how the save would affect the pose of the quadruped's head, and was hoping you might know why. It's weird, right? Any input is appreciated.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Character head poses wrong after loading a save

Post by Tony Li »

That should be valid code, although you can change the line in the script to this in case your project has a conflicting script named SceneManager:

Code: Select all

UnityEngine.SceneManagement.SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
Does a script control your quadruped's head, for example to look at or follow a target? If so, maybe that target isn't loaded or the script can't find it.
PeaceCat24
Posts: 6
Joined: Wed Nov 13, 2024 4:27 pm

Re: Character head poses wrong after loading a save

Post by PeaceCat24 »

yes, we have look at and aim scripts on the character. I'll add them to the multi active saver and try it. Thanks again
edit: i mean the component saver, whose actual name eludes me
PeaceCat24
Posts: 6
Joined: Wed Nov 13, 2024 4:27 pm

Re: Character head poses wrong after loading a save

Post by PeaceCat24 »

Still loads with head down :(
PeaceCat24
Posts: 6
Joined: Wed Nov 13, 2024 4:27 pm

Re: Character head poses wrong after loading a save

Post by PeaceCat24 »

Now her head is staying up. Not sure what changed it, but our code guy changed seemingly unrelated code, and I added more components to the saver. Here's hoping the fix is permanent. Still confused, but....
Thanks again for your help, Tony Li!
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Character head poses wrong after loading a save

Post by Tony Li »

Glad it's working now at least!
Post Reply