Playmaker Forum

Playmaker Help & Tips => Playmaker Help => Topic started by: picklesandtickles on January 11, 2018, 02:59:53 PM

Title: [SOLVED] Object appear at mouse position
Post by: picklesandtickles on January 11, 2018, 02:59:53 PM
Hi All,

I'm trying to create a situation where click on the screen makes an object on the screen appear where the mouse clicked. Right now, I can only get the object to move in little increments. This is for a 2D game. Here's what I have in Playmaker:

Left Click, Store Mouse Position, Move Character (https://imgur.com/a/aw43W)

The object "Click and Move" is an Empty object whose child is the Ball Sprite. It's a normal 2D object. I set the X,Y,Z to be 0 for both the empty object and the ball sprite. Thanks for any help you can provide.
Title: Re: Object appear at mouse position
Post by: omgitstri on January 11, 2018, 04:11:58 PM
Hello,

Because your Get Mouse Position is set to Normalized, I think it is grabbing a value between 0 and 1, if you uncheck Normalized it might work.
Title: Re: Object appear at mouse position
Post by: jeanfabre on January 12, 2018, 12:30:50 AM
Hi,

 First, tweening is not ideal here, unless the mouse position is only valid as you click, but what if the user click and drag, does your feature needs to follow? if yes, then use the action MoveTowards and set the distance to 0 so that it constantly move towards even if it reached the position 100%.

Also, did you check out the Ecosystem sample : MoveTowardsWithConstraint

it's a sample where you click and the object will go to that position under the mouse click position, I added some constraints, but that's just for illustrating, you can remove the constraint feature if you want.

 Let me know how it goes,

 Bye,

 Jean
Title: Re: Object appear at mouse position
Post by: picklesandtickles on January 12, 2018, 07:07:40 AM
Hi guys,

Thanks to both of you for the suggestions - I will give them a try today and will stop back by later with an update. Jean - I hadn't tried MoveTowardsWithConstraint, but I will definitely give that and Move Towards a try to see the varying results. Thanks again. Stay tuned.
Title: Re: Object appear at mouse position
Post by: picklesandtickles on January 13, 2018, 10:42:28 AM
Hello,

This question has been solved. Thank you! I used the Ecosystem Sample Move Towards With Constraints as a model. I was able to replicate the states, events, and actions from that sample within my own scene. Doing so causes the Target object to appear wherever there is a mouse click on the screen. No I can use that as a basis for some more complex interactions. Thanks again for your input!