Set Position Rounds Floats To Integers

1 sentence description of the problem: The set position block rounds floats to integers.

Steps to reproduce the problem every time:
(Start in a blank draft if possible)

  1. Add Object
  2. Put a float in the Set Position block

I expected this to happen: Precise positioning

But instead this happened: Rounded :/

Screenshots/video:
Example


Device details:
image

4 Likes

That’s why I often use a variable, but it’s so annoying to have to make a variable just to get precise positioning.
(At least I’m pretty positive using a variable works, if not I’m going to go insane because I thought it worked all this time, lol…)

4 Likes

Unfortunately, this is intentional by design. Same goes for a lot of the other traits like speed, tilt %, and rotation.

Plus, if the position was precise, it would still really only show every 0.5 units (1 actual pixel), as opposed to every 1 unit. And even that can feel tiny if you’re using a large screen…

It has been this way since Hopscotch was first released, lol.

3 Likes

Variables are able to store floating point values, but the position will always be rounded. But since yellow variables don’t round to the nearest integer, it works out perfectly.

3 Likes

Set position does not round. The X position trait is rounded

3 Likes

I always thought it did round since the object only appears to change its position visually every 1 unit (even when trying to microstep with the help of yellow variables).

4 Likes

That’s would be fine, I’m trying to get a text from the corner of a screen to the centre without actually setting the angle (keeping it at 0 degrees). Obviously the screen isn’t square so y would have to be a current+0.* if x is current+1. I don’t really care how it shows, it is just really annoying that with that code, the y position is rounded to 1 and is near to the top.

3 Likes

Already tried that, does not work lol

2 Likes

Which corner are you attempting to move from? Bottom left? Top left? Etc…?

And does the initial position start with the text center aligned with the first point, or are you using its origin point?

And for the movement, are you looking for linear movement or some sort of ease-out movement?

2 Likes

Omg, I’ve been doing that for so long now, lol XD
Well, good to know I don’t need to do it anymore :P

2 Likes

Like this? >:)

Move to Position Custom Block v1.1 by Crosbyman64

(The steps part is how many frames you want it to take to get to the final position.

E: just updated it so it doesn’t take more than a frame to begin its movement…

(Advanced Mode is disabled in this project)

3 Likes

Yeah, that works, how come your set position doesn’t round lol
This is my attempt lol: . by Dog Icing

3 Likes

The main difference is I do the changes in the yellow variables, then set the position to those two yellow variables. The reason it works is because yellow variables will keep the floating point values precise (to the best of its ability)

The reason yours don’t is because you’re referencing the position traits at every step, which you know rounds to the nearest integer (which I believe was done for simplicity and understandability).

The only time I use the position trait is to get its initial position. Mine will also work from any position.

3 Likes

that’s because the canvas draws only the number of pixels in the stage. If you inspect the main.stageProject’s stage objects, you’ll see that they do take decimal values. However, because of the x position thing being rounded, you can’t do things like x position += 0.2 as mentioned

3 Likes