Play animations at runtime

Hi Kapa bot, I got Multiplayer and player control working including animations for the local player. Once we join a room the other player can not see my animations (for example walking animation) and vice versa. I do see the player moving around, but only the animations do not execute. I have tried the tutorial on syncing Custom Data, but have no luck so far. Can you maybe explain to me how to make it so I can see other players' animations?
Solution:
if you use mechanim for walk animation it can be driven by velocity so there's no need to sync the walk animation
Jump to solution
11 Replies
kapa.ai
kapa.ai10mo ago
Hi @Hippolicious || CardaStacks. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. However, based on the information provided, it seems like you might need to synchronize the animation data across the network. This could potentially be done by creating a custom Realtime component that syncs the animation state, similar to how the color of a cube is synced in the Synchronizing Custom Data (https://normcore.io/documentation/realtime/synchronizing-custom-data) guide. You might also find it useful to check out the XR Avatars and Voice Chat (https://normcore.io/documentation/guides/xr-avatars-and-voice-chat) guide, which includes information on creating custom avatars and might provide some insight into how to handle animations. Remember, the key is to ensure that the animation state is being correctly communicated to all clients in the multiplayer room. If you're still having trouble, I would recommend reaching out to the NormalVR support team or community for more specific guidance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai10mo ago
<@366873530199179264> kapa.ai is still learning and improving, please let us know how it did by reacting below
Hippolicious || CardaStacks
@Normcore Assistant I understand how to change the color using a custom Realtime Component. How do I change animations using a custom Realtime Component?
kapa.ai
kapa.ai10mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Based on the provided extracts, there isn't a direct example of synchronizing animations using a custom Realtime Component. However, the process would be similar to synchronizing other types of data, such as the color example provided in the Creating a RealtimeComponent subclass (https://normcore.io/documentation/realtime/synchronizing-custom-data#creating-a-realtimecomponent-subclass) section of the documentation. Here's a general outline of the steps you might take: 1. Create a Realtime Model for the Animation State: Similar to the ColorSyncModel in the provided example, you would create a model to hold the state of your animation. This might include variables for the current animation, the time within the animation, or any other data that's necessary to replicate the animation state across different clients. 2. Generate Model Code: If you're using Unity 2021 or newer, Normcore will automatically generate the remaining code needed to use your model. The extra code exists as temporary C# code generated when your project compiles. You can read more about this in the Generating model code in Unity 2021 (https://normcore.io/documentation/realtime/synchronizing-custom-data#generating-model-code-in-unity-2021) section. 3. Create a RealtimeComponent Subclass: This component will be responsible for updating the animation state on the model and responding to changes in the model's state. You would override the OnRealtimeModelReplaced method to handle changes in the model, similar to the ColorSync example in the provided extracts. 4. Update the Animation State: Within your RealtimeComponent subclass, you would have methods to update the animation state on the model and to update the animation in your game based on the model's state. This would be similar to the SetColor and Update methods in the Using a model (https://normcore.io/documentation/realtime/realtimecomponent#using-a-model) section. Remember, the key is to ensure that the animation state is being correctly communicated to all clients in the multiplayer room. If you're still having trouble, I would recommend reaching out to the NormalVR support team or community for more specific guidance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai10mo ago
<@366873530199179264> kapa.ai is still learning and improving, please let us know how it did by reacting below
Hippolicious || CardaStacks
Yeah I have been trying that... OK I will keep trying. At least I know I am on the right track.
Solution
Mechabit
Mechabit10mo ago
if you use mechanim for walk animation it can be driven by velocity so there's no need to sync the walk animation
Mechabit
Mechabit10mo ago
for other animations you can sync an int for each one then you increment the int when you want to trigger the animation you listen for the change event on the client and trigger the animation locally
Hippolicious || CardaStacks
That makes a lot of sense! Thanks! 🙏
Mechabit
Mechabit10mo ago
or if you have a finite state machine you can sync the state, when the change event is triggered you start the animation transition but this method doesn't work if the state is the same and you just want to retrigger the same animation cos no change event is sent I suppose if you do have a FSM you'd want to sync the state anyway and have an extra int for triggering animations
Hippolicious || CardaStacks
Yes! it works when I use velocity for the player movement and using a realtime model! Thanks a lot for the help! ❤️