I'm playing some animations through a c# script. The other animations reset when one animation plays. How can i stop that from occurring?
It's as i stated in the title of the post. In the c# script, i'm not using any other methods except "GetComponent<Animation>()" & "Play()". Each animation is being played within a completely different function. The animations are of opening & closing doors. When i open a new door, the last open door goes back to its default state of being closed. I want the doors to stay open unless & until i close them. All doors & all animations are added to a single object, which is a car model prepared by my coworker. It has one joint bone for each door. There's no skinned mesh renderer component.
Here's one of the fuctions:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class handle : MonoBehaviour
{
public GameObject Car;
private Animation anima;
public bool bootspaceAnim = false;
void Start()
{
anima = Car.GetComponent<Animation>();
}
public void bootspaceHandle()
{
if (bootspaceAnim == false)
{
anima.Play("Bootspace_Anim");
anima["Bootspace_Anim"].speed = 1.0f;
anima["Bootspace_Anim"].time = 0;
bootspaceAnim = true;
}
else
{
anima.Play("Bootspace_Anim");
anima["Bootspace_Anim"].speed = -1.0f;
anima["Bootspace_Anim"].time = anima["Bootspace_Anim"].length;
bootspaceAnim = false;
}
}
}
Answer by ahiyantra · May 17 at 07:26 AM
Separating the scripts/controllers for all animations finally resolved the bugs. It seems that the animations interfere with each-other when they're manipulated using a shared script/controller.
Your answer
Follow this Question
Related Questions
2D Slide Animation 0 Answers
Help: NPC Animation from trigger animation back to idle animation C# 1 Answer
Trigger stuck at full in state machine 0 Answers
Recorder window not appearing 0 Answers