Here’s the deal: I’m sending out a raycast from the player , and when against a certain collider with a certain key input i want it to trigger an animation and toggle a boolean.If it’s true then play animation 1 and toggle to false, and if it’s false, play animation 2 and toggle to true.
My problem is that the boolean stays false, and the whole event behaves as if it were always true.Here’s my code attached to the player.
#pragma strict
var watereye : GameObject;
var eyewelldown : boolean;
function Start ()
{
watereye = gameObject.FindWithTag("eyewater");
}
function Update ()
{
if (Input.GetButtonDown("action"))
{
var forward = transform.TransformDirection(Vector3.forward);
var hit : RaycastHit;
if (Physics.Raycast(transform.position,forward,hit,2))
{
if(hit.collider.gameObject.tag == "eyewellcollider" && eyewelldown==false)
{
watereye.animation.Play("eyewaterdown");
eyewelldown = true;
}
if(hit.collider.gameObject.tag == "eyewellcollider" && eyewelldown==true)
{
watereye.animation.Play("eyewaterup");
eyewelldown = false;
}
}
}
}
Any help would be greatly appreciated, thanks.