Camera chop on move

Hi when I move my camera to the new position it freezes about every 1.3 seconds when I move it



just wondering what this might be about? thanks

2 Likes

It seems like that in the web app it’s not possible to look around while the camera itself is moving. It works on mobile though. We are going to have a look at it.

But we can prevent it in your example. This is because both “move” blocks are being executed repeatedly even though the rocket and the camera are already at their target position. It always makes sense to introduce a boolean in such cases to set and check for a certain state.

With that it should work like expected.

1 Like

Thanks for the help, so the “on update” functions as a infinite loop?
Just to be clear at the start the variable is set to false----->active rocket---->-------update loop----->if not true (false) run if/do-----> inside if do variable becomes true so the code stops updating? Sorry about my logic I am just trying to warp my head around this :slight_smile:

Yes, you’re right. At the end the “on update” event listener is still active and the outer check is still being made (if not hasReachedTarget) but because it doesn’t evaluate to true, the inner code blocks don’t run anymore.

Regarding your first question - it’s not the same like an “infinite loop”. In general, an “infinite loop” sounds never like a good solution for any kind of programming task. It was used here in Blockly to get some specific tasks done but in my opinion it was never the “right” thing to do.

That is why we have introduced the “on update” block which is essentially a function and all the code blocks inside “on update” are being executed for every frame. So if your scene runs at 60 frames per second (60 fps) the code inside “on update” is being executed 60 times in one second.

In many scenes you will find yourself in a situation where you need to check for some custom states all the time and then react to it. Now you can use the “on update” block for this.

Thanks for the answer. I teach grade 5/6/7 so how these blockly examples are working are going to be key to having my kids (and myself!) understand how to build :+1: