- Home /
Trying the get a Pickup key script working, need some help.
This is what I've got so far. I was working on it at Work so I may have messed a few things up, but I can't figure out what. Appreciate the help!
#pragma strict #pragma implicit #pragma downcast
//this is the collector script, it works in tangent with the pickup script. while the pickup script allows items to be //"collectable"... this script allows a player to be a collector. there are action states as below: COLLECTOR SCRIPT (this script) GOES ON TOPMOST PLAYER OBJECT
//there are numerous other scripts, each of which interact with collector script, each of those get attached to your collectable object: //each of the following states (except huntingSeeking) have their own pickUp script:
//huntingSeeking (used as null action. 90% of the time, the script's action will be set to this.) //picking (this is the half second while you're picking the item up) //speededUp (used for the speed boost, increases your speed by speedboost var) //speedTrap (used as trap, to slow down char for set amount of time.) //jumpPlus (used to increase amount player can jump.) //healthy (used to boost player health) //keyItem (used as key (important) item, and also has the option of instagating cinematic cut scenes.) //scoreBoost (used to increase players scor by set amount)
static var itemNum:int; static var keyItemNum:int; var allKeyItems : int; static var action : String;
var stringAction : String; var stringToEdit : String; var stringScore : String; var stringPicking : String = ("Picking up something tasty");
var pickScript : GameObject;
var camera1 : Camera; var cinecamera : Camera;
//the "Start" function resets the item pickups all to false. function Start (){ }
//the following functions are utilized by the various action states, and are the effect of picking up each type of pickup. function playClip(){ //a function that switches the camera from main camera to cinematic camera camera1.enabled = false; //turns off the main camera cinecamera.enabled = true; //turns on the cinematic camera }
function stopClip(){ //a function that returns the camera to main camera from cinematic camera camera1.enabled = true; //turns off the main camera cinecamera.enabled = false; //turns on the cinematic camera }
//end action state functions
function OnGUI () { // Make a multiline text area that modifies stringToEdit. stringToEdit = GUI.TextArea (Rect (10, 10, 400, 100), stringScore, 200); stringToEdit2 = GUI.TextArea (Rect (10, 120, 400, 100), stringAction, 200); }
function Start () { itemNum = 0; action = "huntingSeeking"; }
function Update () {
stringScore = ("Hello, this is your gui score window!\nNumber of Items Collected:" + itemNum.ToString()); stringAction = ("You are currently: " + action);
if( action == "huntingSeeking"){ stringAction = ("You are currently: " + action); }
if( action == "inrange"){ stringAction = ("In range of pickup!!"); }
if( action == "picking"){ stringAction = ("Picking up something tasty"); }
if( action == "keyItem"){ pickScript.GetComponent("pickupKey"); //set key item # to true stringAction = ("You found something important! Playing cinematic!"); playClip(); if(keyItemNum == allKeyItems){ //what do you want to do when ALL key items are picked up? }
if( action == "speededUp"){ pickScript.GetComponent("pickupSpeed"); //set character speed to itemvalue in pickupspeed stringAction = ("Speeding up!"); }
if( action == "scoreBoost "){ pickScript.GetComponent("pickupScore"); itemNum = itemNum + pickupScore.itemValue; }
if( action == "healthy"){ pickScript.GetComponent("pickupHealth"); //increase character health to itemvalue in pickuphealth stringAction = ("Increasing health"); }
}
What isn't it doing? Are there any errors? I noticed you have commented the Start() function, but there is no code in it.
Why two Start() functions? Why the "(" and ")"in:
var stringPicking : String = ("Picking up something tasty");
?
Answer by delow · Dec 06, 2012 at 01:03 AM
yes sorry I'm getting tons of compiling errors, i deleted the 2nd start, but now it's saying that my "pickupScore" isn't a variable, not sure what sort of variable to make it.
Your answer
Follow this Question
Related Questions
Pickable item to unlock doors (Being able to proceed next scene) 2 Answers
Problems with key script 0 Answers
Change Colider to Raycast instead? 2 Answers
FlashLight Fixes Please?? 1 Answer
pickup with key 1 Answer