Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » Trying to change the target of the main camera by using Ray casting and clicking.

Trying to change the target of the main camera by using Ray casting and clicking.

View previous topic View next topic Go down  Message [Page 1 of 1]

ryand444


Member [Lv. 0]
Member [Lv. 0]
So i have been trying to change the target of the camera a variable within the same script that has the camera lock onto a specific object by having the player click on the object when the Raycast detects any object with the tag "Cell" .
I can't seem to be able to change the Target variable i have tried using a string that records the name of the raycast object and then applies it to the target but it does not help at all.

string TargetName = "Targetsname";
RaycastHit vHit = new RaycastHit();
Ray vRay = Camera.main.ScreenPointToRay(Input.mousePosition);
TargetName = vHit.transform.gameObject.name;
if (vHit.transform.gameObject.tag == "Cell" && Input.GetMouseButtonDown(1))
{

this.target = Targetname;

}

Any help you can give will be much appreciated
Thanks for your time and patience.

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum