playMaker

Author Topic: Drag and drop again :)  (Read 2269 times)

Gida

  • Playmaker Newbie
  • *
  • Posts: 48
    • View Profile
Drag and drop again :)
« on: November 13, 2015, 08:37:06 AM »
Hey everyone!

I ran into a problem right now. Just a quick description:

I Want to build some kind of Rotating Table (rotatable by swipe gesture) in 3D Space with two or three prefab-images on the left side of the screen in 2D Space.
(Maybe a GO, an image attached to the Camera or Gui Element).

On mouse press down / on touch on one of these Image, the specific prefab should be spawned at the cursor on the left.
Now the User should be able to drag the spawned prefab by Hand on a specific Position. A non visible Trigger Collider would send a "move_to" Action on the mouse-release. When the Prefab hits the Collider it shall be detroyed and the former invisible Geometry shall turn to visible (turn active).

Now the user should be able to build up some Towers standing beside each other.

There should also be the posibility of unhiding the lower part all on just a button-press and the reset the whole scene and hide all again.

I will add an image to make it more clear.

How would you do it?

Cheers.

P.S. I will come up with more info about my problems and my state machine. But I must leave right now :D.

Have a good weekend everyone.



« Last Edit: November 14, 2015, 11:48:13 AM by Gida »

Gida

  • Playmaker Newbie
  • *
  • Posts: 48
    • View Profile
Re: Drag and drop again :)
« Reply #1 on: November 14, 2015, 10:25:33 AM »
So Hello Everyone,

here is my Topic. I want to build some kind of "contruction-kit" wich runs on pc and touch devices.

I undertand scripting and Playmaker but as always.... still very new to it.  :P

There schould be graphical representaions like an "Icon" of the Parts on the screen. As soon as you click/touch the Icon, the prefab will spawn (Create Object) the Prefab and lock on the mouse / finger as long as youre dragging it around. The User should drag it to the assumed correct place and if it is the correct, the GameObject will attach to the desired Position (like a 3D Puzzle). So you should be able to build e.g. a Castle.
The whole Scene should be viewble from a 180° view and be turnable.

So I started with the Ground giving it a collider with a "Mouse Drag" Script. The spawnable Prefab GameObject like the towers had a "Drag on Mouse Down" Script attached to it. As soon as the desired Position is reached (Trigger Event) a move Towards Action is launched and on Mouse Button Up the Prfab snaps to the Collider. If no Collision is detected, the Prefab shall return to its Icon and  we're at the start again.

So my Problems are:

1. How to check the Collisions if the Scene is turned? If i got the GameObject attached to my Mouse and it intersects optically but they do not touch...

Case: the GamObject and the Collider are on one raycast line from the POV but the Colliders do not intersect.)

2. Whats the best way, to make a correct Order for the Gameobjects to be placed at the specific Locations. E.g.: You shouldnt be able to place a tower in the Air and it stays there, while the basement is not even in Place. Should I store the Objects with an Array?

3. How to make a Reset Button best? Add tags and hide/Spawn the Gameobjects all?

Answers would be appreciated. :) Thanks for readin through

Cheers
« Last Edit: November 14, 2015, 10:37:35 AM by Gida »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14593
  • Official Playmaker Support
    • View Profile
Re: Drag and drop again :)
« Reply #2 on: November 16, 2015, 06:09:53 AM »
Hi,

 ok, so , I recently learned  (thanks to Magnus!!) that the new Unity event system actually works for 3d colliders with no code modification, only how you setup the evensystem!!

http://forum.unity3d.com/threads/eventsystem-how-do-you-use-idrophandler-ondrop-with-3d-objects.317683/

basically you add a 3d raycaster to the camera!

knowing this, you can simply take the UI sample on drag and drop and do everything using these uGui drag and drop proxies!!

else, you can of course do that manually, by listening to trigger enter and exit events.

to answer you specific questions:

1: collisions are always turned on. so if nothing happens it's a bad setup or simply that the colliders indeed are not colliding!

2: order it game specific so you will need to keep track of that using for example arrayMaker where you order in a list the objects in the right order and compare that with the user pile. Or each object knows what's next and you ask the object if the next object is correct.

3: reset is also up to the game implementation. a good technic is to send a global event and each gameobject have an fsm they can respond to that reset call individually. Keep a dummy for each object that will always be active and simply turn off the child which would be the actual visiable gameobject, this way you always can reach a gameobject even if not "visible" to the user.

Bye,

 Jean

Gida

  • Playmaker Newbie
  • *
  • Posts: 48
    • View Profile
Re: Drag and drop again :)
« Reply #3 on: November 16, 2015, 08:03:10 AM »
Many thanks Jean,

uhm.... :-X i was already good into playmaker and now i looked up the ecosystem too. And now for Arraymaker.... ok :)

As far as I understood, it is a System for including arrays into playmaker. Right? But is there a quick overview or any Tuts?

Thnx again.


edit: saw the documentaion in the files. Will have a look :))
« Last Edit: November 16, 2015, 09:36:32 AM by Gida »

Gida

  • Playmaker Newbie
  • *
  • Posts: 48
    • View Profile
Re: Drag and drop again :)
« Reply #4 on: November 16, 2015, 01:26:24 PM »
Sorry, still  not getting anywhere.

ArrayMaker has no Documentation I get a grip on. I planned to do it with an Array and Gameobjects wit IDs, but i cant get it to work. :(
Since this is an urgent matter for me, I would be happy about an quickanddirty Solution as well.

 I just want the same Gameobject to snap to distinct points. The Gameobject can be with MEshrenderer turned off as well and activate when intersecting and MouseUp.
The User should just experience, that he has pulled the right object to the right place.

Each Point has a Collider and can only be used once. When the Gameobject is in Place, the Collider shall turn off.

I get it to work with my Solution for one Collider. But since its a Prefab (with one FSM) I seem to be unable to switch to other Colliders in the "moveto"-Action because you can only add one Gameobject. So it snaps always to the same...  But I want it to snap to the collider it intersects with.


My Solution for the FSM is as follows:

Gida

  • Playmaker Newbie
  • *
  • Posts: 48
    • View Profile
Re: Drag and drop again :)
« Reply #5 on: November 16, 2015, 01:39:16 PM »
I hate being a nuisance but just an Example:
(Sorry to mention another Company)

this comes close to what i am trying to achieve:

http://www.tasharen.com/ngui/example11.html

the Goal is only to drop the same respawning Objects at distinct places (if they are not supposed to be there they will return to spawnpoint) to build a desired End state (which can be reseted).

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4586
    • View Profile
    • jinxtergames
Re: Drag and drop again :)
« Reply #6 on: November 17, 2015, 01:08:56 AM »
Hi,
for arraymaker you can find some tutorials here

Gida

  • Playmaker Newbie
  • *
  • Posts: 48
    • View Profile
Re: Drag and drop again :)
« Reply #7 on: November 17, 2015, 08:12:33 AM »
Thank you.