Hi to all.
how can i get a point in distance “dist” on a direction? like this code:
Quaternion startAngle = Quaternion.Euler(0,hangle,0);
Quaternion angle = transform.rotation * startAngle;
Vector3 tdirection = angle * Vector3.forward;
Vector3 tpoint;
now i want get a point like “tpoint” in distance 6 unit on direction “tdirection”.
thanks
Looks like tdirection is now a unit vector pointing in a direction you’d like. You can multiply it by any float X to get a similar vector, X units long, pointing in the same direction.
Vector3 tpoint = tdirection * 6f;
If you want a position relative to the attached GameObject:
Vector3 tpoint = transform.position + tdirection * 6f;
(Footnote: be cautious about performing operations like this when you’re not sure if the input vector is normalized to a unit vector. Yours should be, here. When in doubt, normalize.)