- Home /
Swipe Drag Select Gameobjects :( ?
http://www.youtube.com/watch?feature=player_detailpage&v=Pns5fW-92B0#t=70s
Like in the game-video posted above ... how can I drag my finger from one gameobject to other gameobjects and detect where I went and what I collided with. Basically I am trying to check if the player swipe pattern was what I wanted...if the player selects(drags\swipes finger) gameobject in a particular manner ...select A ,then select C and then select B ... then do something {} ...hope my question made sense its 6 am and I am still trying to put thoughts to logic :( ..help appreciated
Answer by robertbu · Apr 12, 2013 at 01:34 AM
Assuming your buttons are 3D game object in world space, you can approach this problem in one of two ways. You can use the OnMouse*() functions to capture input. For example put the following function in a script and attach it to an object:
function OnMouseEnter() {
Debug.Log("Entering");
}
With this method, each individual object would be responsible for reporting its own input to some central script.
Another way is to use Physics.Raycast(). Using this method, your detection code will centrally located. Google "Unity3d Physics.Raycast" and you will find 1000s of posts on this site, most including some source code to study. With this method, your tiles will need to somehow uniquely identify each tile value. You can do this by using the GameObject.name, or you could attach a script to each tile and have a global variable you set. This variable would be read by the script that does the Raycasting.
@uv: Don't post comments as answers. Use the "add new comment" button below a post. Answers should answer the question.
I've converted your answer to a comment.
ps.: dont't forget to tick an answer as solution when your problem is solved. Also upvote answers that has been useful.
Your answer
Follow this Question
Related Questions
Is there an Editor Window "IsSelected" equivalent for popup windows? 2 Answers
Swipe Movement On A Grid 1 Answer
Swipe & gesture controls for android 1 Answer
Character Dress Up 0 Answers