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 Alp-Giray-Savrum · Aug 10, 2013 at 12:36 AM · gameobjectprefabsvariablesmouseclickincrease

Getting MouseEnter to Another Object

Hello, I'm trying on my game again and I couldn't find any Documentation about this problem. As you can see the picture below I'm shooting the Duck. alt text

When I shoot the duck, Counter should incrase and MissionBoard should decrase. They have their own code. The Counter's code is at below

 #pragma strict
 
 var counter : int;
 
 var LeftDuck : GameObject;
 var RightDuck : GameObject;
 
 
 function Start () {
 
 }
 
 function Update () {
 
 counter++;
 
 var Text : TextMesh = gameObject.GetComponent(TextMesh);
 Text.text = counter.ToString();
 
 Debug.Log(counter);
 
 
 
 
 }

I'm using Update Method Because of I don't know what to write :D I hope some one can help. I Want this exactly.

when i click to LeftDuck(Clone) or RightDuck(Clone) object, Increase variable "counter".

Please I only need this code and then my project finishes. Thanks a lot.

ekran alıntısı.jpg (213.6 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by coolfireking2 · Aug 10, 2013 at 09:05 AM

Hello,

This may not be the best way to do it but this will work, Make a new script called something like DuckShoot in java script then write this in function update

 if(Input.GetMouseButtonDown(0)){
 NameOfScriptWithCounterOn.counter += 1;
 NameOfScriptWithMissionBoardOn.MissionBoardVariable -= 1;
 }
 // 0 stands for left click, 1 for right and 2 for middle

Next you need to open your Counter code script and your mission board script and add static to your variables e.g.

static var counter = 0; or static var counter : int; static var missionBoard = 0; or static var missionBoard : int;

then you are done! The only downside with this is that if you have a reset or reastart button then you will need to set the counter var back to 0 and the mission board to what the next mission is.

Joseph

Comment
Add comment · Show 2 · 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
avatar image Alp-Giray-Savrum · Aug 10, 2013 at 10:53 AM 0
Share

Hmm. $$anonymous$$, I'm using Perfabs so in-game objects are (Clone) :/ Does it affect Whole ducks or shoud i create a "Contoller Item" ?

avatar image coolfireking2 · Aug 10, 2013 at 03:18 PM 0
Share

with this script having your duck have (clone) after it doesn't matter. You do not need to create a controller item.

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

Reinitialize prefab 0 Answers

mouse click obj to initiate action, then locking the obj so action cant be repeated 1 Answer

MouseClick and gameObject 1 Answer

changin functionality of gameobject/script without loosing variables C# 1 Answer

Distance interaction 0 Answers


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