Hii,
in my scene i have placed a chair, i added a message to check when i click on this object
so it prints prefect
print(“You hit an object”);
now i want to change the camera position when it hits the object
to see whats happening, u can also see my screen cast ::
http://www.screencast-o-matic.com/watch/cXhOXMF3r
so my code goes -------
var tagName : String; // allow the designer to make a tag in the inspector
var rayDistance : float = 0; // length of the ray for our raycast
function Update () {
if (Input.GetMouseButtonDown(0))
{
print ("yes the button works");
var hit : RaycastHit;
var ray : Ray = camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast (ray,hit,rayDistance))
{
if (hit.transform.tag == tagName)
{
print("You hit an object");
var position = Vector3(8,1.8,0);
var getFPScam = GameObject.Find("FPScam");
getFPScam.transform.position = position;
//camera.main.transform.position = position;
var getFPS = GameObject.Find("FPS");
getFPS.transform.position = position;
}
}
}
}
problem coming is strange - my camera leaves my fps body when i click the object, here is the package if u want to download n see