- Home /
Question by
SB3154 · Mar 25, 2017 at 08:53 AM ·
camerascripting problem
Some scripts not working after closing unity
I am using an older version of Unity for school, and when I close out of Unity, when I load back into it, one of my scripts doesn't work. Every time I have to remove and reapply the script for my game to work. My unity version is Unity 4. something, not sure with these school computers. If anyone has had a similar problem and found a fix, I would greatly appreciate the answer.
This script is attached to my main camera on the FPS controller. #pragma strict
var rayLength = 10;
private var treeScript : TreeController;
private var playerAnim : PlayerControl;
function Update() { var hit : RaycastHit; var fwd = transform.TransformDirection(Vector3.forward);
if(Physics.Raycast(transform.position, fwd, hit, rayLength))
{
if(hit.collider.gameObject.tag == "Tree")
{
treeScript = GameObject.Find(hit.collider.gameObject.name).GetComponent(TreeController);
playerAnim = GameObject.Find("FPSArms_Axe@Idle").GetComponent(PlayerControl);
if(Input.GetButtonDown("Fire1") && playerAnim.canSwing == true)
{
treeScript.treeHealth -= 1;
}
}
}
}
Comment
Your answer
