Hi everyone. I have come across a problem where I can’t get my camera to rotate when I click on a collider. I want to be able to click on a collider and have the camera rotate to look at a different collider. I am trying to create a more “interactive” menu but so far it has gone nowhere as I cannot seam to fix this. I’m new to scripting, so if possible it would be nice to get any ideas in JavaScript.
1 Answer
1Combine these 3:
C# example
void Update() {
if( Input.GetMouseButtonDown(0) ) { //Left Click
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if( Physics.Raycast( ray, out hit ) ) {
Camera.main.transform.LookAt( hit.transform );
}
}
}
Can you explain what happens in this, because I don't really understand C# very well. Thanks
– Red_Sentinel
What you already have now? Can you post it here? Be more precise in your description, get my camera to rotate when I click on a collider can mean any of these 3 (or perhaps more): 1. Click on collider, camera rotate and look at collider 2. Click on collider, camera rotate in a specific axis 3. Click on collider, camera rotate randomly (shaking?)
– Chronos-LSadly I don't have anything at the moment (as I said I'm new to scripting) but click on collider, camera rotate and look at collider fits what I want most.
– Red_Sentinel