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 chunjai · Feb 22, 2011 at 06:26 AM · gameobjectarrayclickmouseclickselection

selected object in array lost in translation

in piece script ::

function OnMouseUp(){
    isSelected = true;
    if (currentPosition == corner){
        var pathSelectorClone = Instantiate(pathSelector, yada yada);
    }
}

goes to the pathselector script ::

function OnMouseUp(){
    var piece = GameObject.FindWithTag("someTag");
    if(piece.GetComponent(SomeScript).isSelected == true){
        piece.GetComponent(SomeScript).movePiece();
    }
}

which goes back to piece ::

function movePiece(){
    (motion logic here)
}

since the piece is a prefab and part of an array, something gets lost in the middle of everything above... my selected piece is no longer the one that moves. when you click on the pathselector, the last piece in the array is the one that moves to it. so i suppose 'isSelected' isn't doing anything. any suggestions? i can provide more detailed scripts if that helps.

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 johan-skold · Feb 22, 2011 at 01:49 PM 0
Share

What would help is a bit of explanation around the concepts of your code. What is a piece? What is the path selector? What array is it you're speaking of? What has the "someTag" tag? What are you trying to accomplish? How does that differ from what's currently happening? Etc.

avatar image chunjai · Feb 22, 2011 at 09:39 PM 0
Share

Totally yeah. Sorry, late night. This is for a board game. Four pieces per player. When you roll the dice you have to select re piece you want to move, then select the location on the path you'd like to move to (the path branches off with shortcuts). I have an array of player pieces, and I can get them to move along a path by just tapping a piece. When I add in the logic to have the piece wait until I choose a path for it to move to the selected path (shortcut or general) all hell breaks loose (the piece I selected no longer is 'selected' and ins$$anonymous$$d the last piece in the array moves.

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

No one has followed this question yet.

Related Questions

Selecting One Piece, Moving to Selected Area 1 Answer

script optimization (choosing an object in game by click) 1 Answer

How to copy part of an array 2 Answers

Getting the Script component of a GameObject in an Array 1 Answer

How To Get A Reference To All Nearby GameObjects? 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