linnik

Vehicles rotate after restaring server

Recommended Posts

Hi,

I save vehicle position and load it when server starts. Every time it's happening, vehicle rotation changes. Vehicle turns right after every loading.

Parking: 

2h708bq.jpg

After restart:

1zev8dt.jpg

Any suggestions?

Share this post


Link to post
Share on other sites

Are you loading the vehicles 'heading' position? xyz won't set the rotation. You can get the vehicle heading through player.vehicle.heading; and when you spawn the vehicle, there's a 'heading' property.

Share this post


Link to post
Share on other sites
2 часа назад, MrPancakers сказал:

Are you loading the vehicles 'heading' position? xyz won't set the rotation. You can get the vehicle heading through player.vehicle.heading; and when you spawn the vehicle, there's a 'heading' property.

I use vehicle.rotation. Vehicle.heading has only getter, setter doesn't work.

Edited by linnik

Share this post


Link to post
Share on other sites

OMG. Why is it still so inaccurate? Red line how I left it before saving, red how it spawns after restart.

5d3yxf.jpg

Цитата

let Vehicle = mp.vehicles.new(
            Model, 
            new mp.Vector3(parseFloat(Data["position"]["x"]),parseFloat(Data["position"]["y"]),parseFloat(Data["position"]["z"])),
            {
                heading: parseFloat(Data["position"]["h"])
            }
        );

 

Share this post


Link to post
Share on other sites

Haha, this is ridiculous!

In vehicle file I have 229.50584411621094 after spawning with this heading I've got vehicle.heading = 130.494140625 and vice versa when vehicle saved with the heading 130.494140625 it becomes 229.505859375 after restart.

Edited by linnik

Share this post


Link to post
Share on other sites

Not precise heading:

Цитата

Vehicle: 359.9999999999999(file) 359.9999694824219(vehicle.heading after setting)

So I can say that vehicle.rotation works but both heading setter and vehicle.rotation round float in a some weird way.

Edited by linnik

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.