playMaker

Author Topic: Kind soul needed to help with Mouse Up and Mouse Down  (Read 1744 times)

cdutoit

  • Playmaker Newbie
  • *
  • Posts: 28
Kind soul needed to help with Mouse Up and Mouse Down
« on: February 04, 2015, 10:26:33 PM »
I love playmaker and the tutorials helped a lot. Where I really struggle is when trying to use the input events.

I'm trying to port to Playmaker a "flight control" game - where you select a plane and then draw a flight path for the plane to follow.

I don't want to use Mouse Drag since that will be hard to port to touch. The existing code for the game that I'm trying to port (C#) makes this very easy:

Code: [Select]
void Update ()
{

//if we are controlling the plane and the game is not over
if (controlPlane && !player.gameover)
{

//if mouse button is up
if (Input.GetMouseButtonUp(0))
{
//set controlPlane to false
controlPlane = false;
}

//get mouse position
inputPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
// do stuff

}


}

//if click or touch the plane
void OnMouseDown()
{

    // Do some stuff...details not important

//set controlPlane to true
        controlPlane = true;


}
    }



Very simply, in the mouse down function they set a boolean to true.

Then, in the update function they simply look for this boolean to be true and if it is, simply grab the current mouse position.

In playmaker, I can create a state with a global transition for MOUSE DOWN and set the boolean to true.

But then I'm lost...where would I put the corresponding code of the update function?

I've tried all different kinds of things and can't crack which should be a simple port. I'd be happy to hear any and all suggestions  - or even otherwise of implementing a "click and draw" implementation in Playmaker.

After 4 days of struggling I figure it's time to turn to the experts!

Thanks in advance
Chris

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Kind soul needed to help with Mouse Up and Mouse Down
« Reply #1 on: February 05, 2015, 07:32:52 AM »
You don't really need to maintain the bool anymore if you're porting this to Playmaker. You can just use Mouse Down to make a direct transition to another state where you do your Screen To World Point and include a Mouse Up action that fires an event back to the previous state.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

cdutoit

  • Playmaker Newbie
  • *
  • Posts: 28
Re: Kind soul needed to help with Mouse Up and Mouse Down
« Reply #2 on: February 06, 2015, 07:40:25 AM »
Thanks, Lane.

I'm making progress, albeit slowly. Sometimes its easier to code it than to use Playmaker but I'm determined to get this modeled as FSM's.