playMaker

Author Topic: Mouse/Touch throw Direction Actions  (Read 1386 times)

BISLY

  • Playmaker Newbie
  • *
  • Posts: 1
Mouse/Touch throw Direction Actions
« on: November 09, 2016, 10:17:03 AM »
hi jean,
hi all

im having trouble with making a "paper toss" mechanism with the mouse actions.

i get the position of the mouse and translate it to world point, set the position of the object i want to move, etc.
everything is working great, except i didnt mange to do 2 things:

1.i dont know how to translate the angle of the mouse swipe/drag to a directional z rotation. i tried mouse look, or subtracting the end Mouse X to the start X position and sample curve it to degrees measurements, Vector 3 operators, and a lot of creative stuff. but no luck there. what is the most straight-forward simplest way of achieving this?

2. for now, as i release the mouse button,  i set a force in a z direction by taking the distance between the release position and the initial click.
Meaning- the force amount does not take to account the speed/time of the swipe, only the distance. How can i measure the speed of the mouse drag to use it to calculate the force amount according to it.

I was surprised to discover there is no tutorials on this, considering this mechanism is used in so many mobile games. my end goal is also to translate the mouse actions to touch actions (i have input touches). is there any difference in approaching it, regarding mouse as opposed to touch?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mouse/Touch throw Direction Actions
« Reply #1 on: November 18, 2016, 02:56:09 AM »
Hi,

1: it depends what you want to do in the end with that angle? a direction should be enough as a quaternion or by simply using the custom action Get Signed Angle to target or GetAngleToTarget

2: speed of swipe needs to record both timestamps of press and release and then you divide the distance by the time between the press and release.


Bye,

 Jean

 bye,

 Jean