A couple of questions about lecture 123

There are a couple of things that are not clear to me:

  1. I believe we should not be substituting both values in snapPos with the gridSize. It seems more logical that we should divide by 10, round to closest integer and then multiply by the grid size we want.

  2. If I translate a cube and THEN modify the gridSize range slider, my cube moves back. How can I make it so that the slider does not influence the new position when changed again?

Hi Oliver,

  1. That’s probably a matter of personal preference. Please feel free to do it your way. :slight_smile:

  2. Your cube moves back to what? What does “new” in “new position” mean? Take a look at your code. How and where does the slider value affect the position? Did you implement any restriction that prevents something from happening?

I’ve figured out that for the first point, Ben’s way is better as you have to move the mouse less further to get a “roundable” number.

For question 2, I am stumped!

I mean that if I set gridSize to 10 with the slider, then move the cube, then change the value of gridSize, the cube moves as I change the value of the slider. I would like it to only affect the amount the cube moves when dragging the cube, not when changing the slider value.

In that case, you’ll have to write your own solution. The cube must send a message to the instance that arranges the cubes.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms