Ok, first off, i am still a bit of nub when it comes to code, so bare with me
I am able to send values to scripts in the same gameobject, but for some reason i cannot find a way to send values to a script on another gameobject.
I have a gameobject called book. When the player picks up the book, the book is deleted and a skill point would be added to the skill points manager as part of the character stats. The book and the code for picking up the book is on one gameobject, and the skills stuff is on the Main Camera.
My last experiment was using sendmessage, and here is the code for it. If there is something else i should be using, throw it at me
Skills_pane
var spoint : int = 0;
function skillpoint(spoint : int){
spoint += 1;
}
skillbook
var dist : int;
var player : Transform;
var book : Transform;
function Start () {
}
function Update () {
dist = Vector3.Distance(player.transform.position,book.transform.position);
if (dist == 1) {
if (Input.GetKeyUp("e")) {
gameObject.SendMessage ("skillpoint");
DestroyObject (gameObject);
}
}
}
Anything anyone can suggest will be a lifesaver.