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
1
Question by ahackett · Jul 17, 2013 at 08:44 PM · javascriptapikongregate

Help with Kongregate API?

Hi! I'm new to Unity. I upload my games to www.kongregate.com, and I'm trying to upload the score from the game to the website. The guide to the API from the website is very unclear to a beginner and I cannot understand it. I am wondering if anyone has used it before or is experienced and can explain how to script this. Document for using the API with unity3d: http://www.kongregate.com/developer_center/docs/en/using-the-api-with-unity3d Any example would be great. Here is the script for my player (which handles the game's score). I want to pass it through to another scene with a script attached to the Main Camera that handles loading the API and submitting the score. Thank you!!! //Player Script

 //Inspector Variable
 var tagName             : String;             //allow the designer to setup a tag
 var rayDistance         : float = 0;         //length of the ray for our raycast
 var score                    : int = 0;             //score for our player
 var gameTime            : float = 20.0;     //the amount of time the game will last
 var requiredScore    : int = 20;             //the amount of score required to win the game
 //Private Variables
 
 //Called once
 function Start()
 {
     InvokeRepeating("CountDown", 1.0, 1.0);
 }
 
 //Update is called every frame
 function Update () 
 {
     //use mouse button to select on game objects in the scene
     if(Input.GetMouseButtonDown(0))
     {
         var hit : RaycastHit;
         var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         if(Physics.Raycast(ray, hit, 100.0))
         {
             if(hit.transform.tag == "enemy")
             {
                 //var position = Vector3(Random.Range(-4,4), Random.Range(-4,4), 0);
                 //hit.transform.position = position;
                 var enemyScript = hit.transform.GetComponent(scriptActorEnemy);
                 enemyScript.numberOfClicks -= 1;             //Reduce the number each click
                 if(enemyScript.numberOfClicks == 0)             //Check that the object is destroyed (0 clicks)
                 {
                     score += enemyScript.enemyPoints;          //Add points to our overall score
                 }            
             }
         }
     }
 }
 
 function CountDown()
 {
     if(--gameTime == 0)                             //subtract from gametime
     {
         CancelInvoke("CountDown");           //cancel the countdown
         //yield WaitForSeconds(3.0);              //amount of time before loading next scene
         if (score >= requiredScore)
         {
             Application.LoadLevel("sceneScreenWin");
         }
         else
         {
             Application.LoadLevel("sceneScreenLose");
         }
     }
 }
 
 function OnGUI()
 {
     GUI.Label(Rect(10, 10, 100, 20), "Socre: " + score);
     GUI.Label(Rect(10, 25, 100, 35), "Time: " + gameTime);
 }
Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

15 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 avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Cannot initialise Kong API 2 Answers

How do I implement the Kongregate api 4 Answers

Using the Kongregate API 1 Answer

How to make a selection system? 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