What is wrong with this code?

This script is dependant on a script called “Camerascrolling”
I get no Error, but the script isn’t working either…

private var cameraScrolling : CameraScrolling;

private var Selected = 0;

var targets : Transform;

function Awake () {

cameraScrolling = GetComponent (CameraScrolling);

cameraScrolling.SetTarget (targets[0], true);

for (var i=0; i < targets.Length; i++) 
	targets*.gameObject.SendMessage ("SetControllable", (i == 0), SendMessageOptions.DontRequireReceiver);*

if (Input.GetKeyDown(KeyCode.Alpha1))

cameraScrolling.SetTarget (targets[0], true);

  • cameraScrolling.SetTarget (targets[1], false);*

  • }*

  • if (Input.GetKeyDown(KeyCode.Alpha2))*

  • {*
    cameraScrolling.SetTarget (targets[0], false);

  • cameraScrolling.SetTarget (targets[1], true);*

  • }*

  • }*

Without knowing what camera scrolling does, it’s hard to really say. Two suggestions:

  1. Make sure that you’re actually pressing alpha1 and alpha2; those are the numbers along the top of the keyboard, NOT the ones on the number pad.
  2. Try putting in some Debug.Log calls into your code at various points in that method to see which points are being reached, if any. Right now you don’t know if your Awake method is being called at all, if the key events are happening, or what. If all those things are happening, then you have more complex sleuthing to do. But for the moment, best just to knock out the easier-to-verify stuff and go from there.