Hi i have been struggling creating button that’s function is to rotate camera around when it is being pressed.
A good starting point in adding UI buttons is the following example:
You can add your custom logic to rotate an entity when the button is pressed or released.
You may find this example useful as well, it showcases how to rotate an entity using the mouse:
well i have created UI with buttons but I am not able to manage how to make camera rotate only if I hold the exact button pressed.
Try sharing your project or at least a sample project that reproduces your issue to take a look!
this may be the case
i need to make camera rotate as the let’s say left arrow button is being pressed
Looking at your code, it seems like you’re on the right track, but there are some adjustments you might want to consider making. You initial approach to have a variable that is tracked in the update function that is affected by button events is correct.
I see that you are also subscribing to the button event in the update function. This is not necessary and should be moved to initialize since repeatedly adding listeners can be quite costly.
I personally would separate your keyboard and button press scripts to make it easier to manage. You could then create a boolean script attribute in your button script that determines whether the button moves the camera left or right on click and multiply your Euler values appropriately.
I hope this is helpful.