playMaker

Author Topic: Move 2d object with mouse  (Read 2075 times)

Thorz

  • Playmaker Newbie
  • *
  • Posts: 2
Move 2d object with mouse
« on: July 17, 2014, 06:55:49 PM »
Hello everyone,
What I'm trying to accomplish is move an object on the X axis using the mouse such as a breakout game when moving the paddle along the X axis.

I was able to do this using the arrow keys in playmaker but can't seem to get it to work with a mouse. I have tried Mouse Pick but have had no luck. I basically need to tie the X axis of the paddle to the X axis of the mouse.

I have also searched through all of the playmaker tutorials but can't seem to find what I am trying to do.

Thanks

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Move 2d object with mouse
« Reply #1 on: July 17, 2014, 08:50:08 PM »
How are you moving the paddle?

At a high level, off the top of my head the way I would first approach it is doing Mouse Pick against a floor and storing the hit point as a vector3. Thats basically the world position of where the mouse is at. Once you have that you can pull the X value out of the mouse pick vector3 and save it in a float, then do Set Position on the paddle and only change the X value.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Thorz

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Move 2d object with mouse
« Reply #2 on: July 17, 2014, 11:00:42 PM »
Thanks for the suggestions Lane, I am currently moving the paddle with the arrow keys but want to move it using the mouse.

I tried your suggestion and it move the paddle but only a very short distance. During the slight move, the paddle keeps flashing (stuttering) back to its original position. Once the mouse moves past the original paddles position, the paddle snaps back to its original position.

I used the Mouse Pick action and stored the position in a V3 variable called mousePos and checked every frame. Under the mouse pick action, I placed the Set Position action and chose the mousePos variable as the vector and then selected the X axis. After my mouse hovers over the paddle, it grabs it but only moves it a short distance before snapping back to its original position.

I also checked the Late update but that didn't change anything, any other ideas?