Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 erlantzlor · Apr 28, 2020 at 03:31 PM · dragcardcardsinherit

Get child name from another parent

I'm doing a Hearthstone style game. Is there any way to get the gameobject's name from another parent where my card is positioned at the end of the drag?

Comment
Add comment · Show 4
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 endasil_unity · Apr 28, 2020 at 03:49 PM 0
Share

It is probably possible to do what you want but I do not quite understand what you want to achieve / mean. Another parent? Parent of what? Do you want to know what game object your card is positioned over? Do you have any code / sketches / images to clarify what you want help with? Generally you can use OnTriggerEnter to see what your object collides with (https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html) and from the collider get the game object your colliding with and its parents / children whatever it is you need. But perhaps with some more details it becomes easier to help you do what you want.

avatar image endasil_unity · Apr 28, 2020 at 08:51 PM 0
Share

If you have collision box and trigger on the parents of the cards you could do something like this if you have this code on parent/ card A and want to drag it onto parent of card B (and you have named it cardBParent) and find it's name private void OnTriggerEnter(Collider other) { if(other.gameObject.name="cardBParent") {

foreach (Transform currChild in other.gameObject.transform) { Debug.Log ("Child found. Name: " + currChild.name); } }

avatar image erlantzlor endasil_unity · Apr 28, 2020 at 10:09 PM 0
Share

Didn't work. I'm not using collision boxes, i'm with draggable and dropzone. I tryed to add box colliders, but I didn't understand really well how they work.

avatar image endasil_unity erlantzlor · Apr 29, 2020 at 08:35 AM 0
Share

Damn, my $$anonymous$$d reading skills are a bit rusy. ;)

If you show the code, information about what object you have it on as well an image of your editor with the hirarchy it would be easier for me to explain what you need to do to get what you want from what you have.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by erlantzlor · Apr 28, 2020 at 06:59 PM

I have 2 cards, each one inside a diferent parent. I want to drag A card to the B, which is in a different parent, and show on the debug the name of the B card. Sorry if I expressed bad the first time.

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

Answer by Cassos · Apr 28, 2020 at 07:53 PM

Please provide some code or something we can work with

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

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

Related Questions

Trading card game uniqe id generation 2 Answers

setactive true in OnBeginDrag 1 Answer

trading card game question with board element 0 Answers

A little hand with a Card Game 0 Answers

Playing Cards With Special Shrinking & Twisting Effects 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