Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: eirsik on February 02, 2014, 01:53:32 PM

Title: Make object follow cursor [SOLVED]
Post by: eirsik 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
Title: Re: Make object follow cursor
Post by: jeanfabre 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
Title: Re: Make object follow cursor
Post by: eirsik 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?
Title: Re: Make object follow cursor
Post by: jeanfabre 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
Title: Re: Make object follow cursor
Post by: eirsik on February 07, 2014, 01:30:22 PM
Great! Thanks!