I want to access a parameter in the animation I made called Shooting which is set by default to false. I want to change it to true when the enemy is inside the player’s trigger. How do I do this? Can you post the script? Sometime before i’m 70 would be nice…
So I started c# a few months ago and from what I can tell this is how you do it:
using UnityEngine;
using System.Collections;
public class LevelComplete : MonoBehaviour {
Animator animGoal;
int GoalHash = Animator.StringToHash("GoalDone");
// Use this for initialization
void Start () {
animGoal = GetComponent<Animator>();
}
void Update ()
{
if(blahblahblah){
animGoal.SetTrigger(GoalHash);
}
}
so you need to use Animator.stringToHash as you think you would use “GoalDone” from this example
BTW you may want to use a bool for something called shooting
In the API it talks about function that can be called in the Animation interface called CrossFade and there are actually plenty of other fading and transitioning effects that can be done. I would take a look here: Animation
This being said, if you want to control it strictly by script you’ll need to use that and plenty of other functions provided in Animation. Otherwise you’ll have to use the animation transition in the inspector of the animation controller.