Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by delow · Dec 05, 2012 at 02:39 AM · pickupkey

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"); }

}

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image T27M · Dec 05, 2012 at 03:09 AM 1
Share

What isn't it doing? Are there any errors? I noticed you have commented the Start() function, but there is no code in it.

avatar image bompi88 · Dec 05, 2012 at 12:24 PM 0
Share

Why two Start() functions? Why the "(" and ")"in:


var stringPicking : String = ("Picking up something tasty");
?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges