Topic category: User side tutorials
Are you making a mob and ran into an issue where sometimes you think you spawn something in the right place, test it out and it all works, but when you try it at a later date, perhaps in a new world it is suddenly offset by 1x, 1z or both?
This is an issue related to whether the coordinates you are at in the world are positive or negative. At a positive world coordinate, everything works perfectly, however at a negative coordinate it is offset by 1. You can simply correct this in a procedure through:
if x < 0
set varX to x - 1
else
set varX to x
if z < 0
set varZ to x - 1
else
set varZ to x
Then simply use varX and varZ whenever you spawn something at a specific coordinate and everything will work fine! End of the tutorial.
If you're still not sure what the problem is exactly:
I made a tutorial in which I created an "isUnderwater" check:
https://www.youtube.com/watch?v=nDoclprdfV0&t=77s
At 1:25 you can see that I checked the block at x-1, y, z-1. This is because I tested it previously and whenever I was in the water, it would check the blocks besides it. I hadn't thought much of it and thus checked what the offset was and ended up with x-1, y, z-1. As you can see at 2:54, this yields the correct result. However for those who do understand this issue, you might have guessed my coordinates: yup! It was a negative coordinate for both x and z! The offset I displaced in my tutorial would have malfunctioned in a positive x/z or both!
It is therefore unsurprising to see in the procedure above that if x < 0 and z < 0 both z and z are offset by -1, as that correlates with the offset I showed in my tutorial video, Make sure to always keep this in mind when spawning things into your world! Use varX and varZ not the original ones!
thank u, i needed this
Thank you, it worked :D
How do I get those set local x blocks
Hey how did you get this to work. I'm not sure how he got the "local x" and "local z" blocks
Does this have to do with custom variables, idk how to get teh local x block
This will be fixed in 2020.4
how do we do this in 2020.5