Alright so in my game you are stranded on an island. Your objective is to find 60 rocks, and then return to a point on the island, once that happens I want an animation to kick in zooming out of the islands and the rocks will be arranged to say “S.O.S”, but how do I do that? How do I have the game recognize that I have 60 rocks in my inventory? How do I have the game recognize when i’m in a certain spot with 60 rocks in my inventory, and when that happens have the animation kick in? Thanks. Also, the script i’m using for my inventory is Inventory Master.
Add a Collider marked as “Is Trigger” at the spot on the island you need to return to. Then add a script with the following function attached to it.
[Tooltip("Drag your player's inventory into this slot")]
[SerializeField]
private Inventory playerInventory;
[Tooltip("Set this to the ID of the stone in your inventory system")]
[SerializeField]
private int stoneID;
// Something entered the spot...
void OnTriggerEnter(Collider other) {
// .. was it the player?
if (other.CompareTag("Player") ) {
// If so, rummage through their inventory
List<Item> items = playerInventory.getItemList();
// and count up how many stones they have
int numStones = 0;
for(int i=0; i<items.Count; i++) { if (items*.itemID == stoneID) numStones++; }*
// Do they have enough?
if(numStones >= 60) { SOSAnimation.Play(); }
}
}
weel you have allready your function if(numStones >=60){
Debug.Log(“Do My Animation can play”)
}
But your probleme look like if you know how play the annimation. I suggest you yo put a
''Debug.Log(“Do My Animation can play”)
‘’‘’'()
So, what i doe its …
Animator _animotor;
bool canAnimate;
void Start(){
animator = GetComponent();
}
void Update(){
_animator.SetBool(“CanPlay”, canAnimate);
}
and put your line code inside your trigger function
if(numStones >=60){
Debug.Log(“Do My Animation can play”)
canAnimate=true;
}
adn make sure that your Paramater bool name in your animatorController is the same name as CanPlay in your script.
and dont use the old Lagacy animation. So, set your model as Generic.