Credit´s to Kalaskryss!!!
I´ve now got it working! The reason I´m still here is to ask if there would be a good way to set up the lighting. As far as my knowledge goes, turning lights on and of is dynamic lighting, and it seems to work with < 4 Lights. Do I need Unity Pro or is there another way to make many Lights “configurable”?
If you want to read the script, here it is:
This is the object That illuminates (It´s called ColorChangingCube):
#pragma strict
function TurnLightOf ()
{
light.enabled = false;
}
And this is the script for the hands (basicly the script from the survival game series):
#pragma strict
var TheDammage : int = 50;
var Distance : float;
var Hand : Transform;
var MaxDistance : float = 1.5;
var TheCube;
TheCube = GameObject.Find ("ColorChangingCube");
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
Hand.animation.Play("Punch");
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
{
if (hit.collider.gameObject.Find ("ColorChangingCube"))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("TurnLightOf", TheDammage, SendMessageOptions.DontRequireReceiver);
}
}
}
}
}
It´s propably horrible, but it works fine for me. Please note that my only goal was to be able to turn them of, if I wanted, I could´ve easily implemented to turn them on back again. nevertheless, this is what my code looks like. BTW thats the first script I´ve ever written.