Reputation: 2551
I get the direction by subtraction of two vector3. In this case my gameObject and my mouse position.
Vector3 dir = gameObject.transform.position -
orthoCamera.ScreenToWorldPoint(Input.mousePosition)
I now want to place an object in the same direction but at a limited distance from my original gameobject. That is I need a vector in the same direction but with a magnitude of 0.5. How do I do that ?
Upvotes: 0
Views: 1484
Reputation: 1704
var posn = gameObject.transform.position - (dir.normalized * desiredDistance);
Hopefully this doesn't sound too condescending, but you change a vector's magnitude by multiplying it with a scalar.
Upvotes: 1