Sending raycast to animate a object

Hello

I am trying to animate an object my hitting it with a raycast that is attached to my player character the code for the raycast is below `

using UnityEngine;
using System.Collections;

public class SpellRayCast : MonoBehaviour {
SkeletonController sControl;
public bool skelAwaken = false;
// Use this for initialization
void Start () {

}

void FixedUpdate () {
RaycastHit hit;
Ray ray = new Ray (transform.position, transform.forward);
Vector3 forward = transform.TransformDirection(Vector3.forward) * 10;
Debug.DrawRay(transform.position, forward, Color.green);

	if (Physics.Raycast(ray, out hit)){
		if (hit.collider.tag == "Skeleton") {
			skelAwaken = true;
		}
		else{
			skelAwaken = false;
		}
		}
	}
public bool giveAwake(bool Res){
Res = skelAwaken;
return Res;
}
}

The code for the Object I am trying to animate is below

using UnityEngine;
using System.Collections;

public class SkeletonController : MonoBehaviour {
Animation anim;
Animator anima;
bool awaken;
public Rigidbody rBody;
SpellRayCast awake;
GameObject spell;
	// Use this for initialization
	void Start () {
	anim = GetComponent<Animation>();
	anima = GetComponent<Animator>();
	rBody = GetComponent<Rigidbody>();
	spell = GameObject.FindGameObjectWithTag("Spell");
	awake = spell.GetComponent<SpellRayCast>();
	awaken = awake.giveAwake(Res:awaken);
	}
	
	// Update is called once per frame
	void Update () {
		if (awaken == true) {
			anima.SetTrigger("Awoken");
			anim.Play("Reanimate");
		}
	}
}

Any help would be appreciated, new to programming sure I messed something up

I think you’ve missed a bit here. You need to reference one script from the other.

Try

if (Physics.Raycast(ray, out hit))
{
    if (hit.collider.tag == "Skeleton") {
        hit.gameObject.GetComponent<SkeletonController>().awaken = true;
    }
}

You need to make awaken a public so it can be accessed.

It’s late so there may be typos and glaring errors!