playMaker

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

picklesandtickles

  • Playmaker Newbie
  • *
  • Posts: 13
[SOLVED] Object appear at mouse position
« on: January 11, 2018, 04: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, 12:42:55 PM by picklesandtickles »

omgitstri

  • Playmaker Newbie
  • *
  • Posts: 46
    • My Prototypes
Re: Object appear at mouse position
« Reply #1 on: January 11, 2018, 06: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: 15500
  • Official Playmaker Support
Re: Object appear at mouse position
« Reply #2 on: January 12, 2018, 02: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 17, 2018, 01:50:35 AM by jeanfabre »

picklesandtickles

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Object appear at mouse position
« Reply #3 on: January 12, 2018, 09: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: 13
Re: Object appear at mouse position
« Reply #4 on: January 13, 2018, 12:42:28 PM »
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!