playMaker

Author Topic: Object following the cursor?  (Read 1777 times)

Nils Anderssen

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Object following the cursor?
« on: December 01, 2014, 02:35:05 AM »
Hi,

I am trying to get a game object to follow the cursor, but without luck, so I am wondering if anyone has any good pointers on what to do. I guess the solution to this would be fairly easy, but I have not succeeded in finding it.

Any help is very appreciated.

I have tried a couple of different approaches. The first one is to use the mouse pick action (1, 2 and 3) and get the position from that. That kind of worked, but only when I moved the mouse very slowly. When i moved it somewhat quicker, it only returned 0.0.0 as the position. I used the set position action on the game object, so that returned to that position.

The second approach was to use the get mousex and y action and that worked better, but the numbers I got from it did not correspond with the size of the screen. It only moved a bit in the middle.

To clarify, I am only trying to move the object in X and Y, not Z.


All the best

N.


Nils Anderssen

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Object following the cursor?
« Reply #1 on: December 01, 2014, 06:11:08 AM »
Ok, it is now solved by using the following:

Get mouse position
Screen to world point
Set position

I lacked Screen to World point, and now everything works.

It is kind of typical since I have been looking for a solution on and off for a couple of days now, and when I post the question I finally find the answer ;)


Jimmy P

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Object following the cursor?
« Reply #2 on: December 18, 2014, 07:12:36 AM »
I used mouse pick to achieve this.
I did basically what the guy does in this video: