Currently the developers are putting their own money into JC2-MP to keep the servers online.

Please take a few seconds of your time and disable your AdBlock plugin for our website.

Ad revenue is not going to developers, it is used purely for covering our hosting costs.

 

You are also free to donate, which removes all ads from our website!

Patch 0.3 was just released! Full changelog here: https://t.co/4A50m6IKen

2 years ago

Advertisement
November 12, 2019, 07:29:25 pm

Author Topic: Vehicular Anti-Gravity Bug  (Read 1470 times)

Dev_34

  • Full Member
  • ***
  • Posts: 158
    • View Profile
Vehicular Anti-Gravity Bug
« on: August 11, 2015, 06:16:12 am »
Lord_Farquaad and I have been working on scripts together for a server and have encountered a bug in one of the scripts that he made.
Basically, the script spawns around 3 vehicles per second near the players of the server if they are in a certain area. The linear velocity of the vehicles is set in the creation arguments and propels the vehicles at the players from above or from in front of them at about 100 m.p.h usually. The vehicles healths' are also set to .01 as a creation argument, although the bug persisted when health was not altered.
After being spawned, the vehicle is not handled in any way besides being deleted after 10 seconds. It should be noted that the type of car(not bike) is randomly generated and the bug seems to recur and start with all cars. When the cars spawned around the player(s) hit the ground, they sometimes seem to go in an anti-gravital state, resembling something floating in space. The cars in this state tend to turn slightly at a fixed position.
We did IsNaN() checks on all the vehicles' velocities once per second and this seemed to partially work in detecting AG vehicles, but failed most of the time so we really aren't sure.
When other vehicles collide with a vehicle that is in this anti-gravital state, both vehicles are put into that state, kind of like zombie infection. Interestingly, the loose base-game static objects(like dumpsters and chairs) that can be moved by collisions with players and vehicles are also prone to the AG infection and behave similarly. If one is exposed to AG, it seems that any vehicles spawned(via buy menus) also may not move correctly with varying levels of success with different vehicles.
We put together that the bug was client-side, since if one had been exposed to car AG and went to an area where planes were spawned around the player, the planes would also exhibit this AG. BUT, if someone were to NOT be exposed to car AG and go to an area where only planes were spawned, there would be no AG. If someone who was exposed to car AG and someone who was not exposed to car AG went to the same plane-spawning zone, then one of them would experience the AG and the other would not.
Here is a video captured by one of the victims: https://www.youtube.com/watch?v=MXVtj7OrB14&feature=youtu.be
« Last Edit: August 11, 2015, 07:29:21 am by Dev_34 »

dreadmullet

  • Developer
  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: Vehicular Anti-Gravity Bug
« Reply #1 on: August 11, 2015, 07:34:08 pm »
I've seen this before, but I don't know what's going on. Sometimes the physics engine just breaks for certain objects. My best guess is that it has to do with NaNs. You should try checking for NaNs in everything you input into the API (like Vehicle:SetLinearVelocity) and see if you can narrow it down.

__init__

  • Donator
  • Newbie
  • *****
  • Posts: 43
    • View Profile
Re: Vehicular Anti-Gravity Bug
« Reply #2 on: August 11, 2015, 07:53:45 pm »
Wow, that's rather odd. There are only two times when I've seen something like this happen:
  • When the mass of a vehicle gets set negative or very low
  • When I use certain dropzone mods in JCMP (namely grapplehook melee impulse) and hit a vehicle
Dreadmullet, the first thing I'd check is the masses of all of the vehicles. This looks like the mass is getting set to 0; you can go into a test server and try it out, it looks very similar.

Dev_34

  • Full Member
  • ***
  • Posts: 158
    • View Profile
Re: Vehicular Anti-Gravity Bug
« Reply #3 on: August 11, 2015, 09:13:53 pm »
We've continued testing it today and it seems that physics simply "breaks" completely client-side as dreadmullet mentioned. We still think the problem is client-side, since we started doing mass checks on all the vehicles both on the server and on the client. Nothing seemed wrong on the server mass checks but the client mass checks tended to return higher values from GetMass() and seemed to work efficiently in detecting if the bug was occurring on the client. This is based on the premise we established in a seperate experiment where a vehicle's mass does not change at any point in terms of GetMass() on the client and server if it is spawned and blown up.
Doing SetMass(default mass) on the server when the client detected a strange mass did not fix anything.
If i had to guess, i'd say the bug is being caused by vehicles spawning inside of each other or some other scenario where they collide excessively.

EDIT: I'm no longer sure that mass has anything to do with the AG bug.


« Last Edit: August 12, 2015, 04:19:42 am by Dev_34 »

Lord_Farquaad

  • Full Member
  • ***
  • Posts: 217
    • View Profile
Re: Vehicular Anti-Gravity Bug
« Reply #4 on: August 12, 2015, 12:05:34 am »
When a vehicle enters the water, its mass also becomes higher, depending on how far in the water it goes.  When it leaves the water, its mass reverts back to normal.  This is clientside, as mentioned above.

The problem is that vehicles are spawning with weird client-side masses or obtaining them somehow, be it through excessive collisions or other means.  The parts that fall off the vehicle  also tend to increase the problem because even though the vehicle was removed, the doors and tires that had fallen off will continue to float around, and there's nothing that can be done besides restarting the game.  These floating parts also tend to spread the antigravity as well.

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 451
    • View Profile
Re: Vehicular Anti-Gravity Bug
« Reply #5 on: August 12, 2015, 01:22:57 am »
I ran into this in the past, and after just revisiting it, it seems that it is 100% reproducible if you set NaN or infinite velocities. Vehicle:SetLinearVelocity(Vector3.Forward * 0/0) and Vehicle:SetLinearVelocity(Vector3.Forward * math.huge) both cause the bug. Make sure your numbers are properly passing or failing the NaN check, because different numbers can give weird results.



« Last Edit: August 12, 2015, 01:44:34 am by SinisterRectus »