[SOLVED] Help with coding out this bug

I am working on the same script as earlier and when you click the button to go to the save slot or option selector and go to options (it might also happen if you click start, but there is nothing there yet) it starts vibrating really fast, can someone figure out what is happening?
Link to script: PlayCanvas | HTML5 Game Engine
link to project: PlayCanvas | HTML5 Game Engine

Hi @Linkplayer!

Are you sure this is the only script that controls the rotation of the camera entity at that specific moment?

yes that script is the only script that affects the camera

it is also the only script attached to the camera

It seems like the link is going to the wrong script ClickAndPosition. Looking at your other script, it’s probably a fight between rotating to left and rotating to right.

First suggestion is to use else in some statement and second suggestion is to build in a little marge between left and right. Alternatively you can use a boolean that blocks new rotation if the camera is already on the correct rotation.

I don’t think click and position is affecting the camera, I put it in for the title screen and options screen because they are in the same y-axis rotation area

No I mean the link you shared was going to that script for me. After that I checked your other script.

sorry, I edited the link

I tried everything I thought of and it isn’t working, can you put what you think would work? Because this is just stumping me

You need to debug your script. You can use the console of your browser for this. Add for example console.log('Check 1') and console.log('Check 2') to your script to see if they are executed at the expected moment.

I guess the if statements of line 30 and 40 are fighting.

I don’t see the browser console, I don’t see logs when it happens, and I don’t think I can see the logs without it, do you know how to open the browser console on Chromebook?

The page below can help you. :point_down:


I don’t see the page that opens it for me on chrome

Google learns me: ‘To open the developer console in Google Chrome, open the Chrome Menu in the upper-right-hand corner of the browser window and select More Tools > Developer Tools . You can also use Option + ⌘ + J (on macOS), or Shift + CTRL + J (on Windows/Linux)’.

I don’t have access to developer tools, it won’t let me click it

sorry about the late reply because my family made me get off my computer and then we went on vacation and I did not think of checking back here in a while.

I don’t know how to fix it, I kept trying everything I could think of, including a snap-in-place if not in the right angle script

At the moment I don’t know anymore where in your project I can see the problem.

Did you already try something like this?

yes, but for some reason, the blocks start off fighting over the starting location, but it cannot go back to the position where they are fighting naturally, they might be fighting on phase 2 too, so it doesn’t snap back normally

Sorry, I don’t understand what you mean. What is ‘fighting naturally’?

I guess the solution is to prevent they are be able to fight.

what I mean by that they are “fighting naturally” is that for some reason the first one thinks that it is just a bit too far and reangles it, then the second one in the same frame says “hey, now it is too far this way.” and rotates it back. I may just have to do it so the camera angles a set number of degrees based on the selected number given by what is clicked.