playMaker

Author Topic: [SOLVED] Object appear at mouse position  (Read 83 times)

picklesandtickles

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
[SOLVED] Object appear at mouse position
« 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

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.
« Last Edit: January 13, 2018, 10:42:55 AM by picklesandtickles »

omgitstri

  • Playmaker Newbie
  • *
  • Posts: 42
    • View Profile
    • My Prototypes
Re: Object appear at mouse position
« Reply #1 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.
Tri Nguyen
Game Designer at Nvizzio Creations

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12539
  • Official Playmaker Support
    • View Profile
Re: Object appear at mouse position
« Reply #2 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
« Last Edit: January 16, 2018, 11:50:35 PM by jeanfabre »

picklesandtickles

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Object appear at mouse position
« Reply #3 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.

picklesandtickles

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Object appear at mouse position
« Reply #4 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!