My question is, how can I scale an object only in one axis based on a target position?
I’m trying to implement a laser effect for my 2d game using cylinder objects. I’m using physics.raycast method to find the walls and other collision objects. raycast works perfecty fine, it gives me the exact position(hit.point) of the collision, however I don’t know how to scale my cylinder object in z axis based on that value.
Here is my laser script;
#pragma strict
var hit : RaycastHit;
function Update ()
{
var ray = transform.TransformDirection(0, 0, 1);
Debug.DrawRay(transform.position, ray*1000 , Color.red);
if (Physics.Raycast (transform.position, ray, hit))
{
Debug.Log(hit.point);
}
}
Thank you