Hi everybody,
I have another noob question regarding the use of the camera mouse orbit script that comes with unity.
After a few modifications, the script allows me to drag with the mouse to rotate the camera around the target object. The only issue I have is that when I first click in the viewport to start dragging the camera jumps to a new position based on the distance parameter. Is there a way to make the camera start the rotation from the position I’ve initially set? As a workaround I was thinking to even have the jump happening when I hit play but I was not able to figure out how to do that either…
I hope my ramblings make some sense!
Thanks,
Anton
Any chance you could post your modified script? It sounds like you are basing the camera motion on the distance from the centre of the screen or some other point but you probably want to use the mouse delta (ie, the distance moved on the last frame update). However, it is not easy to suggest anything without seeing the code.
I think I understand your problem…
You have added code to the orbit so that it checks the state of the mouse button. If it is not pressed then it will no longer run the code…
You however need this code to run at least once on startup… Add a private class variable of type boolean called bStarting and set it to true.
Extend the condition of the if statment to include the bStarting variable. Should be something like if (input.GetMouseButton(1)||bStarting)… You will need to set the bStarting to false somewhere in the proc… Home that makes sense…
Hi devans770, you are right, that is what’s happening with the script. Thanks for the help!
Merry belated Christmas everyone!
Anton