Nested touch object checking?

0 favourites
  • 7 posts
From the Asset Store
Surena Touch
$2.50 USD
A wrap from official Touch plugin to export touch/mouse input to other plugins.
  • Hello there!

    I have multiple different interactive objects which overlap each other.

    I know how to pick the top most of an object. And I know how to put these objects into a family and pick the top most of this family. But my problem now is that each of these different objects have different things to happen if clicked/tapped.

    So how can I do something like this:

    If object touched "InteractiveFamily" {
    	Pick top "InteractiveFamily" {
     		If object touched "objectA" {
    			..things to happen..
    		}
     		If object touched "objectB" {
    			..things to happen..
    		}
     		If object touched "objectC" {
    			..things to happen..
    		}
    	}
    }	
    

    How can I pick the top most of different objects and then check which of these is picked?

    Thank you in advance!

  • You simply put the actions for each object within the family in the actions.

    If there is an action for a specific object, but it is not picked, then the action doesn't do anything.

    So pick top instance of family as a condition.

    Actions

    ObjectA - Do something

    ObjectB - Do something

    ObjectC - Do something

    Only the instance that was picked would be affected.

    Alternatively you can add an instance variable to the family/object as a condition to compare against to take actions.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Oh I didn't know that! I thought if it is not picked all of the other objects are affected. But now I see that if another object is picked instead it behaves differently than that. Great to know, thanks.

  • Wait.... you might be right.

    Edit: You're definitely right. Use an instance variable in the family object to identify which object it is (set it on created).

  • Okay I will use instance variables if someone doesn't come up with a better solution. Maybe there is a simple trick or event call for that. :D

  • You can check each object's UID against the Family.UID. Only the matching one will work.

  • That is actually a great idea! I will test this tomorrow.

    Edit:

    I ended up using a similar approach but with object names instead.

    if InteractiveFamily tapped {
    	if InteractiveFamily.ObjectTypeName = "tree" {
    	}
    	if InteractiveFamily.ObjectTypeName = "door" {
    	}
    	..etc.
    }
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)