playMaker

Author Topic: Object Follow Mouse  (Read 13017 times)

crossmanm

  • Playmaker Newbie
  • *
  • Posts: 4
Object Follow Mouse
« on: July 01, 2011, 05:15:36 PM »
Is there a way to have an object follow the location of the mouse without requiring a click?

Thanks,
Crossman

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Object Follow Mouse
« Reply #1 on: July 04, 2011, 03:25:51 AM »
Hi,

 Can you elaborate a bit more? by object, what do you mean? a 3d object, a 2d element of the gui? if in 3d, on what plane or surface should it stick when moving the mouse? etc etc :) then  we can propose solution:) all in all, this is absolutely possible.

 Bye,

 Jean

crossmanm

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Object Follow Mouse
« Reply #2 on: July 04, 2011, 06:18:57 AM »
Thanks for the reply Jean.  The object needs to be a 3D object moving along the XZ plane.  I run into a snag when trying to convert Mouse X and Mouse Y from their normalized coordinates to world space for the object to set it's position, or maybe I'm going about it the wrong way?

Thanks,
Crossman

crossmanm

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Object Follow Mouse
« Reply #3 on: July 22, 2011, 06:00:05 PM »
I'm glad it's possible, but I still haven't figured out how to do it?  I need to be able to use a cube as a 3d cursor that follows the mouse around, interacts with other game objects, and moves the camera around when it reaches the edge of the screen.

LordShaggy

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 50
Re: Object Follow Mouse
« Reply #4 on: July 24, 2011, 03:29:13 AM »
It's late, but I've done this and will show you a few ways how later.... sigh my website just got hit again....<lord shaggy is sad>

gregmax17

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Object Follow Mouse
« Reply #5 on: September 11, 2012, 12:45:49 AM »
It's late, but I've done this and will show you a few ways how later.... sigh my website just got hit again....<lord shaggy is sad>

Is it later yet? I would like to know how to do this!

I would also like my 3d object (cube) to not only follow the mouse, but touch as well.

Anyone want to share how to do this? Thanks

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Object Follow Mouse
« Reply #6 on: September 11, 2012, 06:25:41 AM »
Hey guys did you saw the examples  of PlayMaker. There is one about that. On input MouseClickToPlace.
It´s with the mouse pick action. You just need that.
Bye

gregmax17

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Object Follow Mouse
« Reply #7 on: September 11, 2012, 12:50:20 PM »
Hey guys did you saw the examples  of PlayMaker. There is one about that. On input MouseClickToPlace.
It´s with the mouse pick action. You just need that.
Bye

Can this be updated every frame? I also would like to have my object that moves to the new point (vector3 position), to be a smooth transition. Is that possible with what you are saying?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Object Follow Mouse
« Reply #8 on: September 11, 2012, 05:07:28 PM »
I think I did this in the Angry Ships project... Look in my most recent posts for a link to download the project.

I'm pretty sure I raycast from the camera to the mouse point and save that point's data each frame as a global transform or vector3 for use by other objects based around the mouse pointer's location.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Object Follow Mouse
« Reply #9 on: September 12, 2012, 08:05:52 AM »
Yes it can be every frame.

gregmax17

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Object Follow Mouse
« Reply #10 on: September 13, 2012, 03:56:24 PM »
I think I did this in the Angry Ships project... Look in my most recent posts for a link to download the project.

I'm pretty sure I raycast from the camera to the mouse point and save that point's data each frame as a global transform or vector3 for use by other objects based around the mouse pointer's location.

Finally was able to get to your file. I opened it up and it doesn't answer my question. You are using the raycast to store the vector3 to rotate your starship, and the arrow keys (axis) to move the starship.

I am looking for a way to have my object move towards the raycasted vector3 value.

I did just this, finally. I had to apply the Move Towards action. However, I didn't realize I "should not" set the "Finish Distance" if I wanted it to continue working every frame.

Thanks for your help everyone :)

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Object Follow Mouse
« Reply #11 on: September 13, 2012, 04:12:11 PM »
I think I did this in the Angry Ships project... Look in my most recent posts for a link to download the project.

I'm pretty sure I raycast from the camera to the mouse point and save that point's data each frame as a global transform or vector3 for use by other objects based around the mouse pointer's location.

Finally was able to get to your file. I opened it up and it doesn't answer my question. You are using the raycast to store the vector3 to rotate your starship, and the arrow keys (axis) to move the starship.

I am looking for a way to have my object move towards the raycasted vector3 value.

I did just this, finally. I had to apply the Move Towards action. However, I didn't realize I "should not" set the "Finish Distance" if I wanted it to continue working every frame.

Thanks for your help everyone :)

The Missle's in there use that method.

Glad you got it figured out  ;)
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D