I created an NPC, and the process was pretty straightforward. However, my NPC does not use animations during the cutscene. I keep getting the below error:
Cannot play animation GrandmotherIdle_L (layer 0) on character Grandmother's Animator, Grandmother_Idle_0
My animator looks fine, as well as the other settings.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Welcome to the community, @yang1.
The screenshots look OK. Just to be doubly-sure, the Animator controller in the first screenshot is also assigned in the Animator on the "Grandmother_Idle_0" sprite object, and the Animator component is enabled? I cannot recreate the issue, otherwise.
If so, share screenshots of your character's full Inspector (both the root, and their sprite child), and I'll try to spot the issue.
Thank you for your response. The issue was resolved on its own and the animation problem did not occur when I started the project today. I'm not sure what caused the issue in the first place or how it was resolved.
It's okay if I ask a question. In my cutscene, my NPC moves from point A to point B in real time, and I have to wait for them to walk the entire distance. Is there a way to make the NPC spawn behind the camera to speed up the cutscene?
This is for a 2D game?
It's possible through custom scripting, as you can teleport an NPC to a dynamic position in the scene with the Teleport function.
It'd be a bit tricky to know where exactly to re-position the NPC to, however, as you'd also need to make sure they're still on the NavMesh.
Would this only be for specific cutscenes / NPCs, or all instances where an NPC may be moving? If you can share details on when exactly you'd like the behaviour to kick in, with screenshots of a typical scenario, I can give more specific advice.
Hey Chris,
Yes, this is a 2D game. And yes, this is needed for specific cutscenes that will happen only once.
The current implementation involves the NPC walking into the scene and travelling all the way to the NPC Marker to face the player and begin the conversation. I aim to shorten the lengthy walk by having the NPC spawn behind the camera and then walk to the NPC Marker. Check the screenshot below:
https://prnt.sc/eVxYcJlX1tqJ
If you know that the NPC will be out of view when the cutscene starts, then you can teleport them to a Marker just to the left of the camera when it begins.
Create a Marker, position it to the left of the camera, and then parent it to the MainCamera object. You can then use the Object: Teleport Action to teleport the NPC to it when the cutscene begins.
If, though, the NPC might / might not be visible at the time, then you'd need to check first before doing this. There's a few ways you can do this - scripting would be my choice - but sticking to AC you could rely on a Trigger. If a Trigger is set up to span the visible scene, also parented to the Camera, then you could use it to detect the NPC in its OnEnter / OnExit events. When the NPC enters, you'd set a Local Bool variable (e.g. "NPC is visible") to True, and back to False when they exit.
Thank you very much, Chris. The Object: Teleport Action has solved the problem.