Hi,
Been having problems with getting a projectile to fire at a specific location so I did a test with primitives:
CreateEntity()
{
//Create an CUBE at the Heading (a Vector3)
GameObject g = GameObject.CreatePrimitive(PrimitiveType.Cube);
g.transform.position = i_rcParams.Heading;
//create an Cylinder based on the forward transform of an object with "Look at"
//create an object to act as a "ray"
GameObject c = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
GameObject ray = GameObject.CreatePrimitive(PrimitiveType.Capsule);
ray.transform.position = rcEntity.Transform.position;
//now make the ray look at the heading.
ray.transform.LookAt(i_rcParams.Heading);
//set position of cylinder along the ray forward transform.
c.transform.position = ray.transform.forward * Vector3.Distance(i_rcParams.Heading,ray.transform.position);
}
Am I crazy or should the Cube and Cylinder objects be positioned at the same location? They are not even close. What is more strange, the more I move the rcEntity from the origin of the scene the farther apart the cyllinder and cube objects get created. (The capsule is getting positioned at the rcEntity regardless of location as expected.)