#Yaw/pitch not updating

77 messages · Page 1 of 1 (latest)

marble zinc
#

Trying to add slight camera smoothing mainly as a test, but these setYaw and setPitch methods seem to not work at all. I'm dying tring to figure out why. There are no errors.

let prevYaw
let prevPitch
onEvent('player.tick', event => {
    if (prevYaw == null) {
        prevYaw = event.player.yaw
    }
    if (prevPitch == null) {
        prevPitch = event.player.pitch
    }
    let yaw = event.player.yaw
    let pitch = event.player.pitch
    let yawDiff = yaw - prevYaw
    let pitchDiff = pitch - prevPitch
    if (yawDiff > 180) {
        yawDiff = yawDiff - 360
    }
    if (yawDiff < -180) {
        yawDiff = yawDiff + 360
    }
    if (pitchDiff > 180) {
        pitchDiff = pitchDiff - 360
    }
    if (pitchDiff < -180) {
        pitchDiff = pitchDiff + 360
    }
    let newYaw = prevYaw + yawDiff / 1.005
    let newPitch = prevPitch + pitchDiff / 1.005
    event.player.tell(`Yaw: ${newYaw}, Pitch: ${newPitch}`)
    event.player.setYaw(newYaw)
    event.player.setPitch(newPitch)
    event.player.tell(`Yaw: ${event.player.yaw}, Pitch: ${event.player.pitch}`)
    prevYaw = newYaw
    prevPitch = newPitch
})
fallow vergeBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

tardy trellis
#

you are on the server

marble zinc
#

yeah

tardy trellis
#

player movement is client side

marble zinc
#

shit

tardy trellis
#

incl yaw/pitch

#

either use the client tick event, or sync it using hurtMarked (probably not a good idea cause ping times)

marble zinc
#

still not doing jack, i put it in client.tick

#

hmm

tardy trellis
#

in server_scripts?

marble zinc
#

no

tardy trellis
#

or in client_scripts

marble zinc
#

in client

#

what if i just directly set the yaw by doing player.yaw = newYaw

#

nope

solar ledge
#

try using player.minecraftPlayer.setYHeadRot

marble zinc
#

doesn't seem to work either

solar ledge
#

this is what the boat does, try setting yRot then setting yHeadRot to the player's yRot?

marble zinc
#

still not doing anything 😩

    event.player.minecraftPlayer.setYRot(newYaw)
    event.player.minecraftPlayer.setYHeadRot(newPitch)
#

it's so weird

solar ledge
#

set yRot and yheadRot to the same value

marble zinc
#

ah ye

#

forgot

#

yeah still not doing anything

solar ledge
#

tried myself with some edits and got a result

#

dividing by 0.005 was a bad idea

marble zinc
#

oh lord

#

can you send that here so i can try that out?

solar ledge
#
let prevYaw;
let prevPitch;

onEvent('player.tick', event => {
    if (prevYaw == null) {
        prevYaw = event.player.yaw
    }
    if (prevPitch == null) {
        prevPitch = event.player.pitch
    }
    let yaw = event.player.yaw
    let pitch = event.player.pitch
    let yawDiff = yaw - prevYaw
    let pitchDiff = pitch - prevPitch
    if (yawDiff > 180) {
        yawDiff = yawDiff - 360
    }
    if (yawDiff < -180) {
        yawDiff = yawDiff + 360
    }
    if (pitchDiff > 180) {
        pitchDiff = pitchDiff - 360
    }
    if (pitchDiff < -180) {
        pitchDiff = pitchDiff + 360
    }
    let newYaw = prevYaw + (yawDiff * 3)
    let newPitch = prevPitch + (pitchDiff * 3)
    if (newYaw != prevYaw || newPitch != prevPitch) {
        event.player.tell("===========")
        event.player.tell("Old")
        event.player.tell(`Yaw: ${newYaw}, \nPitch: ${newPitch}`)
        let mcPlay = event.player.minecraftPlayer;
        mcPlay.setYRot(newYaw);
        mcPlay.setYHeadRot(mcPlay.getYRot());
        event.player.setPitch(newPitch)
        event.player.tell("New")
        event.player.tell(`Yaw: ${event.player.yaw}, \nPitch: ${event.player.pitch}`)
    }
    prevYaw = newYaw
    prevPitch = newPitch
})
tardy trellis
#

if you want something readable (not chat spamming) use the debug screen

obsidian adderBOT
#

[Quote ➤](#1125976803266273412 message) Are you tired of having to Alt tab to the log to see debug log statements, or have your chat spammed by stuff? Well I have a solution for you.
Using KubeJS you can add lines to the debug screen, and this is much nicer than either of the other two options.
Client```js
global.debug = {}
const before = "===KUBEJS CUSTOM DEBUG==="
const after = "========================"
ClientEvents.leftDebugInfo(event => {
if (global.debug == undefined) return
event.lines.add(before)
for (let key in global.debug) {
event.lines.add(key + ": " + global.debug[key])
}
event.lines.add(after)
})

Adding things (any script type): ```js
PlayerEvents.tick(event => {
  global.debug.x = event.player.x
  global.debug.y = event.player.y
  global.debug.z = event.player.z
})```
marble zinc
#

well i mean.. the debugging isn't going to be final

#

like it won't stay in so it's fine

solar ledge
tardy trellis
#

its like client.debug_left and client.debug_right

#

you'll need to of opened the debug screen before dumping for probe to catch it

marble zinc
#

okay so that worked but it doesn't have the smoothing i needed

#

hmm

#

it's basically just changing my sensitivity without changing my sensitivity

solar ledge
#

why not just enable cinematic camera

marble zinc
#

because that smooths it way too much and it makes it slower

#

it's supposed to be playable and look smooth

tardy trellis
#

have u looked at how cinematic camera does it?

marble zinc
#

i don't know how to look

#

is there some kind of github to look at source code for mc?

#

because i don't want to look at classes, i want to look at code

tardy trellis
#

there are, but they are illegal

#

do u not have a mod development enviroment set up?

marble zinc
#

no

#

i can see how that'd be illegal though

solar ledge
#

I've found it in my devenv and it jsut passes a different value to the turn method

#

hmm, I'm having too much fun with this

marble zinc
#

that is very odd

#

but nice

#

never knew there was a turn method

ionic bronze
#

is this supposed to be like the camera overhaul mod?

#

didnt know this was possible with kubejs sheesh

marble zinc
#

it's kind of like cinematic camera but actually playable rather than just for scenes

#

like it just has a bit of easing

marble zinc
solar ledge
#

it's a thing from Kubejs TFC to hook up with TFC's calendar in custom climate models

marble zinc
#

ah damn

#

hmm

solar ledge
#

but you could probably just use level.gametime or whatever its called

marble zinc
#

if i do event.level.time then i can try

#

ye

#

if that even works on the client

#

I THOUGHT I GOT MY SMOOTH CAMERA SHIT TO WORK BUT I JUST MADE A PARTICLE ACCELERATOR

#

my yaw has reached lightspeed

blissful scroll
digital herald
thin pewter
#

Seems like your formula for pitch and yaw is… slightly off…

light crystal
#

im not sure if this was suggested but you could use network events to send yaw and pitch to client

marble zinc
#

i figured out that i can just avoid trying to make a script for this and just use Real Camera and configure it a bit