I’m trying to make animations for holding the weapons in my game and i want the animation of the previous weapon to stop how would I do this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SwitchGun : MonoBehaviour
{
//public GameObject Hands;
public GameObject AKM;
public GameObject GrappleGun;
public GameObject boostGun;
//public Animation flip;
void Start()
{
boostGun.SetActive(false);
//Set all weapons false except starter weapon
GrappleGun.SetActive(false);
}
void Update()
{
///Having trouble with toggling equipment
if (Input.GetKeyDown(KeyCode.Alpha2))
{
AKM.SetActive(false);
GrappleGun.SetActive(true);
boostGun.SetActive(false);
GetComponent<Animator>().Play("GrappleHold", 0, 0f);
}
if (Input.GetKeyDown(KeyCode.Alpha1))
{
AKM.SetActive(true);
GrappleGun.SetActive(false);
boostGun.SetActive(false);
}
if (Input.GetKeyDown(KeyCode.Alpha3))
{
AKM.SetActive(false);
GrappleGun.SetActive(false);
boostGun.SetActive(true);
}
if (Input.GetKeyDown(KeyCode.Alpha4))
{
AKM.SetActive(false);
GrappleGun.SetActive(false);
boostGun.SetActive(false);
}
}
}