playMaker

Author Topic: Make object follow cursor [SOLVED]  (Read 3764 times)

eirsik

  • Playmaker Newbie
  • *
  • Posts: 22
Make object follow cursor [SOLVED]
« on: February 02, 2014, 01:53:32 PM »
Hello,

Is it possible to have an object to follow the cursor?

I.e I the player can build a campfire, and when he selects the campfire the campfire model is spawned at the cursor and then the player can move the cursor around to find a nice kozy spot for hes campfire and then left mouse click and the campfire is placed.
EDIT: Forgot that the object must stick to the terrain at all times aswell, Not floating in the air.

Best
Eric
« Last Edit: February 07, 2014, 01:30:58 PM by eirsik »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Make object follow cursor
« Reply #1 on: February 03, 2014, 05:30:11 AM »
Hi,

 use this custom action:

http://hutonggames.com/playmakerforum/index.php?topic=2921.0

once this is performed and you did hit an object, use the action "GetRayCastHitInfo" to get the position of the hit, this will be your position to set your following object to.

bye,

 Jean

eirsik

  • Playmaker Newbie
  • *
  • Posts: 22
Re: Make object follow cursor
« Reply #2 on: February 04, 2014, 04:04:36 PM »
Sorry for a dumb question but where should this script be attached? To the object I want to follow cursor?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Make object follow cursor
« Reply #3 on: February 05, 2014, 04:49:33 AM »
Hi,

 it doesn't matter. Actually as I looked for this more closely, there is already an action for this built in PlayMaker "Mouse pick"

 I have attached a sample.

the key is to either set the cube to layer "Ignore raycast" or set the mouse pick layer mask to only pick your terrain for example.

bye,

 Jean

bye,

 Jean

eirsik

  • Playmaker Newbie
  • *
  • Posts: 22
Re: Make object follow cursor
« Reply #4 on: February 07, 2014, 01:30:22 PM »
Great! Thanks!