Edit: I got a friend to join and it’s a visual problem. Your actual hitbox stays where it should, but your screen goes somewhere else until you stop teleporting. This is because of the effects of gravity screwing with where the game thinks your point of view should be. I fixed it by adding levitation whenever I started teleporting, which fixed the gravity problem and I teleported correctly. Looks like I don’t need to figure out the data command then.
My end goal here is to have a repeating command that makes a player teleport in the direction they are facing in small increments.
what I currently have on a repeating command block:
/execute as @p at @p run tp @p ^ ^ ^.5
While this works normally, it does not work when looking up at a certain angle. Instead, if the player is looking up at maybe a 45° angle or more, it teleports the player as it should, but then when I stop the command, the player teleports to a different location above or below where they were before.
If there is a way to fix this, that would be ideal. However, I assumed that it’s a bug and can’t be fixed, so I moved on to ways to remedy the problem.
I could use the x_rotation selector to simply make the command not work when the player is looking up too far. However, I’d rather not do that. So that’s where the question in this thread came from:
Is there a way to manually reset the player’s rotation to a certain level of looking up? I was thinking of using x_rotation to discern whether the player is looking up too far, and if so, reset them down to the maximum acceptable level for the teleport command to work.
I was searching online and I could not find anything on it. I did, though, see some stuff about rotation mentioned in the /data command, and I was wondering if I could use that.
I personally have never looked into the /data command and I know very very little about the /scoreboard command (the extent of my knowledge is how to select a player from their score using /execute). So anything like this is possible I’d appreciate it if you could ELI5.