altmp / altv-issues

Issues and roadmap for alt:V project
92 stars 17 forks source link

Vehicle handling (initialDriveForce) bug! #681

Closed Mikhalin closed 3 years ago

Mikhalin commented 3 years ago

Client/server version

2.1-dev7 (dev)

Current behavior vehicle.handling.initialDriveForce - does not work

Expected behavior

vehicle.handling.initialDriveForce - apply to the vehicle

Steps to reproduce

alt.on("gameEntityCreate', (entity) => {
    if(entity.constructor.name === "Vehicle") {
        entity.handling.reset();
        entity.handling["initialDriveForce"] = 1;
        try {
            entity.setMeta('defaultHandling', JSON.stringify(handlingToObject(entity.handling)))
            let newHandling = entity.getSyncedMeta('newHandling')
            if(!newHandling) return
            newHandling = JSON.parse(newHandling)
            for(let property of Object.keys(newHandling)) {
                const value = newHandling[property]
                if(property == 'initialDriveForce') {
                    alt.log(entity.handling["initialDriveForce"]);
                } else if(property === 'centreOfMassOffset' || property === 'inertiaMultiplier') {
                    entity.handling[property] = new alt.Vector3(value.x, value.y, value.z)
                } else if(property == 'maxSpeed') {
                    var currentSpeed = parseFloat(value / 3.6);
                    alt.setTimeout(() => {
                        native.setEntityMaxSpeed(entity.scriptID, currentSpeed)
                    }, 1500);
                }
                else entity.handling[property] = value
            }
        } catch(err) { console.log(err) }
    }
});

Context (environment)

I'm just trying to apply handling to the created car via a request from the server to the client using gameEntityCreate

Possible solution

Without concept

ThomasMarangoni commented 3 years ago

Please provide properly formatted code, branch name and version you tested it on.

Mikhalin commented 3 years ago

Please provide properly formatted code, branch name and version you tested it on. alt:V Server and Client version: 2.1-dev7 (dev)

Unnvaldr commented 3 years ago

Edit the issue to match the template, otherwise it'll get closed

Mikhalin commented 3 years ago

Edit the issue to match the template, otherwise it'll get closed

Is everything right now?

Unnvaldr commented 3 years ago

By "doesn't work", you mean that it has no effect on the vehicle handling? And did you test it thoroughly?

Mikhalin commented 3 years ago

By "doesn't work", you mean that it has no effect on the vehicle handling? And did you test it thoroughly?

Yes. Very carefully.

Mikhalin commented 3 years ago

And more: Another function getForHandlingName doesn't work with custom cars, even if I specify the handling Name from handling.meta

On standard car's everything is OK

martonp96 commented 3 years ago

@Mikhalin show me your vehicle resource with handling.meta in it

martonp96 commented 3 years ago

and the code with getForHandlingName

Mikhalin commented 3 years ago

and the code with getForHandlingName

alt.log(alt.HandlingData.getForHandlingName(alt.hash('G63AMG6x6'))); https://imgur.com/a/PQ3wkIm

And link to download resource: https://dropmefiles.com/MF5K1

martonp96 commented 3 years ago

Did you try to set initialDriveForce to any high values to see if there is any change? What do you see when you print initialDriveForce's value before and after setting it? @Mikhalin

Mikhalin commented 3 years ago

This value is applicable, but does not affect the car's handling. I tried multiple values. Similarly with drag Coef @martonp96

aydek commented 3 years ago

it seems that none of the setters that starts with initial work .

martonp96 commented 3 years ago

Things are working in latest dev, i tested them myself.

aydek commented 3 years ago

Things are working in latest dev, i tested them myself.

Could you drop me your code, unless I'm doing something wrong it still doesn't work for me. Tried currend dev and release

LeonMrBonnie commented 3 years ago

Will be tracked in #684