Page 1 of 1
Character head poses wrong after loading a save
Posted: Wed Nov 13, 2024 4:34 pm
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.
Re: Character head poses wrong after loading a save
Posted: Wed Nov 13, 2024 5:22 pm
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);
}
}
}
Re: Character head poses wrong after loading a save
Posted: Wed Nov 13, 2024 7:44 pm
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.
Re: Character head poses wrong after loading a save
Posted: Wed Nov 13, 2024 8:04 pm
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.
Re: Character head poses wrong after loading a save
Posted: Sun Nov 17, 2024 10:11 am
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.
Re: Character head poses wrong after loading a save
Posted: Sun Nov 17, 2024 11:01 am
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.
Re: Character head poses wrong after loading a save
Posted: Sun Nov 17, 2024 11:40 am
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
Re: Character head poses wrong after loading a save
Posted: Sun Nov 17, 2024 11:55 am
by PeaceCat24
Still loads with head down
Re: Character head poses wrong after loading a save
Posted: Sun Nov 17, 2024 1:31 pm
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!
Re: Character head poses wrong after loading a save
Posted: Sun Nov 17, 2024 5:20 pm
by Tony Li
Glad it's working now at least!