So I have multiple animations, and I want then to play progressively.
I have an object with a tag, and I have a raycast projecting from the camera, and when it hits an object with that tag, it sets the Animator’s boolean to true, which plays the first animation. I have this part almost working perfectly.
The second part is what I’m having trouble with. I have a float variable, which increases by 1, every second. And it shows how long you’ve been looking at that tagged object. That works, but I can’t get it to translate that information into the Animator’s parameter.
Here’s what I got:
public float seeingTimeChange;
public float seeingTime;
void Start () {
effects = GetComponent<Animator> ();
}
void Update () {
RaycastHit hit;
if (Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out hit, 1000f)) {
if (hit.collider.tag == "effectObject") {
effects.SetBool ("seeObject", true);
seeingTime += seeingTimeChange * Time.deltaTime;
effects.SetFloat ("seeingTime", seeingTime);
Debug.Log ("You see it!");
Debug.Log (seeingTime);
}
else {
effects.SetBool ("seeObject", false);
seeingTime -= seeingTimeChange * Time.deltaTime;
effects.SetFloat ("seeingTime", seeingTime);
Debug.Log ("You don't see it.");
Debug.Log (seeingTime);
}
}
}
The problem here is, that while seeingTime is changing and displaying correctly in the console, the Animator parameter “seeingTime” doesn’t change. And it’s not a name problem, because I tried naming them differently from each other.