playMaker

Author Topic: Beginner Question - Move game object to mouse [SOLVED]  (Read 1382 times)

Narrows

  • Playmaker Newbie
  • *
  • Posts: 6
Beginner Question - Move game object to mouse [SOLVED]
« on: October 21, 2018, 08:31:41 PM »
Hello there! I'm new to using Playmaker and Unity in general, so please bear with me.

The project is recreating the boardgame KLASK but in digital form, just for fun to help me learn. I'm having what is probably a simple issue, just a little confused on how to proceed.

What i'm trying to do is this: Move my player game object to the mouse position constantly. That's it!

I have an empty game object get the XY coordinates of the mouse, but the player game object is not recognizing the X and Y variables for the Move Towards action.

I'm sure i'm missing a step or two, was hoping someone could help me clarify what they are. Please let me know if you need any other information from me. Any help is much appreciated!
« Last Edit: October 24, 2018, 11:41:58 PM by Narrows »

Athin

  • Full Member
  • ***
  • Posts: 163
Re: Beginner Question - Move game object to mouse
« Reply #1 on: October 22, 2018, 07:34:33 AM »
What I'd do is use a Mouse Pick Action that grabs the mouses Vector3 every frame and store it in a variable.  Then just use a move action using that variable for the game object.

Make sure if you have two different FSM that they share that mouse variable.  Make it a global or use a action to grab that variable to use.

Narrows

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Beginner Question - Move game object to mouse
« Reply #2 on: October 24, 2018, 01:01:48 AM »
What I'd do is use a Mouse Pick Action that grabs the mouses Vector3 every frame and store it in a variable.  Then just use a move action using that variable for the game object.

Make sure if you have two different FSM that they share that mouse variable.  Make it a global or use a action to grab that variable to use.

Hey man, thanks so much for the tip. That's where I'm sorta getting stuck - I'm using an empty game object FSM to grab the mouse XY and store it to a global variable. (Seems to be stored as a float variable, and can only be stored as a float variable.) My other FSM is the player game object using a move action, but the stored XY variables aren't showing up in the move action coordinates to choose from.

I'm guessing it can't read the variable because it's a float and it needs a vector2?

Narrows

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Beginner Question - Move game object to mouse
« Reply #3 on: October 24, 2018, 11:41:31 PM »
Solved. Needed to convert vector 2 to vector 3 and grab that instead. Thanks!