altmp / altv-issues

Issues and roadmap for alt:V project
93 stars 16 forks source link

LocalObject .rot not set correctly #2261

Open dGxxxx opened 6 months ago

dGxxxx commented 6 months ago

Description of the problem

i have for example a specific degree (157.5) (as far as I understood, it can be between -180 to 180). alt:V uses radians, so this degree must be converted to radians in order for the rotation to be correct.

i use new alt.Vector3(157.5, 0,0).toRadians() which returns this value: Vector3 { x: 2.748893571891069, y: 0, z: 0 }

however, when I try to set this radian to a LocalObject, it just doesnt set it to that value, because it is probably out of bound (as you can see the X value is 0.39..., even if its value should be 2.74...). when I het lower radian values, it sets the rotation corectly, but when I get higher radian values, it just doesnt work.

image

this lower value for example, applies correctly:

image

basically, the max value in radian should be 3.14

for (let i = -180; i <= 180; i++) {
    alt.log(i + " " + new alt.Vector3(i, 0,0).toRadians());
}

image

using this code object.rot = new alt.Vector3(3.12, 0, 0);, this is the result: image

Reproduction steps

alt.on('connectionComplete', () => {
    alt.setTimeout(() => {
        let obj = new alt.LocalObject('vw_prop_casino_slot_01a_reels', alt.Player.local.pos, alt.Player.local.rot);
        obj.frozen = true;
        obj.toggleCollision(false, true);

        alt.setInterval(() => {
            obj.rot = new alt.Vector3(2.74, 0, 0);
            alt.log(obj.rot);
        }, 1000);
    }, 3000);
});

image

Expected behaviour

The specific value should be set.

Additional context

No response

Operating system

Windows 10

Version

16.0.143

Crashdump ID

No response

Confirmation of issue's presence