How To Adjust Flick for Perspective?

I’m trying to toss an object with a flick gesture, but I can’t figure out how to take perspective into account. The diagram shows the area where the objects can be tossed from, and the polygon is the playing field (horizontal plane) that stretches out in front of the objects. The camera is behind and above the objects. The arrows represent perfectly straight tosses from each position. By that I mean that the objects would fly parallel to the edges of the field.

My problem is, a flick parallel to the edge of the field would be about 20 deg off the vertical near the edges. How do I adjust the gesture so that a flick parallel to the edge of the field produces a toss that is parallel to the edge of the field? In other words, a 20-deg flick in 2D screen space must produce a zero-deg toss in 3D world space. It’s not a constant, I can’t just subtract 20, as that angle changes depending on the horizontal position of the objects. The angle is larger at the edges and zero in the center.

@John-B

Hi there,

I haven’t worked too much with touch or coding in general… but why complicate things. If I understood correctly - why not just raycast positions of touch start and end, then get the direction vector from these two points, use it’s magnitude as force multiplier.

I once did a test with this kind of idea, you could flick on world space objects, and flick distance was calculated in 3d world space… in meters. Based on that test, this works OK as long as you can flick on (some) “physical” object’s surface, and not empty space.

EDIT: of course you can use some imaginary plane too.

I see that the flick gesture function returns a direction vector. I’m using the X & Y values of that Vector2 for the force applied to the object’s rigidbody, the third force value is a constant. Those values are multiplied by a power value based on the speed of the flick.

obj.GetComponent.().AddForce (Vector3(flick.x * powerValue, fixedValue, flick.y* powerValue), ForceMode.Impulse);

What I need is something like Camera.ScreenToWorldPoint, but that works for a direction instead of a position. How do I convert a direction vector in 2D screen space to a direction in 3D world space?