[Guide] GTA V: Physics and collisions

GTA:V Modding with ZModeler3 discussion.

Moderator: madga182

User avatar
Oleg
Site Admin
Posts: 11180
Joined: Fri Feb 06, 2004 3:54 am
Contact:

[Guide] GTA V: Physics and collisions

Post by Oleg »

GTA V: Physics and collision guide.
Last updated: July 2016.

Physics data is made out of one or more collision volumes with physics properties associated with it. You can assign collision volumes to multiple parts of your hierarchy, but it should not be overweight with collision volumes. For example, you assign a collision volume for chassis, doors and bumpers, but you barely assign collision for suspension elements, or small misc/upgrade parts installed on bumper or trunk. Also, when some object already defines a collision volume for bigger part, it might be enough and smaller parts can omit collision. For example a big part "bodyshell" has no collision, as it's mainly equivalent to chassis model and both utilize the same collision in physics engine.

Only geometry parts can have collision associated with them. All parts of your hierarchy are natively equipped with bounding volumes on export and this might be enough for some small parts like tail lights, reversing signals, headlights, police siren and so on.

Physics of your model is affected by collision components physics data, which includes Mass, Energy and surface properties.

Collision volumes.
Your collision volume could be either geometry object (mesh collision) or a dummy node. All types of dummies except Cone are supported (so you can use Box, Cylinder, Capsule and Sphere dummies). Dummy collision should have Centered option toggled on. Complex shape collision can be combined from a set of simple collision volumes or dummies into a group and this group can be specified as a collision.

In order to specify an object as collision for some part you should append the name of the object with [COL] while the leading part of the name must match the associated owner part name. Such a collision volume should be a child of associated part. For example, the door_dside_f [COL] residing in branch of door_dside_f will be considered as "driver's side front door" collision. Alternatively, you can assign collision into owner compound object as COL state, so your part for driver's side front door being a compound object door_dside_f can include geometries for different LODs and collision volume at a time.
This configuration is compact but has a drawback as you can't toggle visibility of collision and any of geometries at a time, you could see only one of them (collision or one of geometry LODs) at a time.

Simple shapes collision should be made of basic shapes (as low poly as possible) with welded vertices. It is highly recommended to weld vertices, so neighbor polygons share an actual common edge. This will give better results in mesh deformation after impacts. A collision shape on import might be loaded without normals or with odd normals and look smooth. To prevent this, all collision shapes have a Flat shaded rendering mode assigned on them. You can do the same in object's properties:
07_flat_shaded_property.jpg
It is very preferable, but not a must, to convert all collision components into compounds with only one state available: COL. You can do this quickly by toggling on COL state on Structure panel, picking a collision object in hierarchy view and pressing Convert to compound button on Structure panel. It will not take long to convert them all that way. The benefit of this method is that you will be able to show/hide all collisions at once with a single toggle on/off COL state button on Structure panel. This is solely for your convenient and not much important for the exporter.

Shape collision volumes.
There are two types of shape collision volumes: the one that can be deformed, and the one that will not. In most of cases, a deformable collision shape is used for the outer side of your model and non-deformable is used on the inner side. Most of boats and planes use non-deformable collision for "interior". You can create any of these types and specify which collision type you prefer by settings collision mesh vertices format Deformable option:
08_deformable_shape_property.jpg
Deformable shape should be a solid volume with no holes or volumes that are separate from the rest. If you need a complex volume, made it out of several simple volumes and combine them into a group. Additionally, deformable shape should specify the degree of deformation by shifting points of collision volume in Damaged state. You can toggle on Damage state on Structure panel and shift vertices of collision volume into inner side (reducing the volume of the object) to some degree. The following image shows a front bumper collision in default state and in "Damage" state:
09_front_bumper_col_damage.jpg
The green color shape is an original volume, and blue is a Deformed (damaged) shift/offset variant. This is mix screenshot, you will not be able to see it that way in ZModeler, you could see either original or deformed state only.

Shape collision volume specifies surface properties on polygon IDs. This is a numeric value locate in Properties->General->External State -> ID. I don't have the full list of used IDs, you can check original models and make your own observations on a subject. The image below shows a chassis collision shape with polygons selection. All selected polygons use ID 142 that probably means "no bullet tracing, no colliding with other volumes". It allows collisions for doors and door windows not to "hit" the collision of chassis itself, when you close the door. At the same time, it bypasses bullet tracing on these polygons that allows doors and door window collision volumes to trace bullet in that area and react properly.
10_chassis_col_id_and_flags.jpg
You can also see a "Default Compatibility" flags set expanded. These flags are used by game to determine surface behavior in damaged state. I don't have a list of these flags yet, it's up to you to retain them as close to original models as possible.

The most commonly used set of IDs (and flags) are:

116 = metal surface. Sparks are drawn when bullet hit and round metallic bullet shell is drawn when impact detected. This also includes drawing of metal scratches on surface after collision with other objects in scene. No additional flags required usually.
117 = cloth (soft top) surface. Usually equipped with flag #2
120, 121, 122 = glass surface with very low, low and medium stamina. 120 is used for door windows, 121 is usually a rear windscreen and 122 is usually a front windscreen. Usually equipped with flag #3 and flag #8.
123 = non-breakable glass. Can be found on boats small windows.Usually equipped with flag #2 and flag #3.
142 = no hit-test area. Used mostly on chassis collision. Usually equipped with flag #3 and flag #4.


Primitive volume collisions.

You can use dummy helpers of Box,Sphere, Cylinder and Capsule primitives as collision volumes. These have to be create or configured to have Centered option toggled on. Cylinder should use Axis X and Capsule primitive should use Axis Z to conform game needs. The surface property is in ID and compatibility flags too (see paragraph above).


Wheel collision.

Vehicle wheel collision must be made as centered Cylinder dummy node on Axis X. It's size could be adjust in "Dummy properties" in properties window. X-scale is the width of the wheel (and tire tread effect), Y-scale and Z-scale should be identical and these are wheel radius.


Collision groups.

It usually happens that certain collision volume can be made out of several simple convex volumes. In such a case, it is very preferable to create collision as a group of simple convex shapes. You can see this in most of truck or utiltruck models, that have an open trunk. In current version of ZModeler, groups are not editable, so you can't reach group items properties or edit geometry of such an objects. You will need to ungroup them to make editable and group them back when done. When group is inside a compound node, such a compound node must be dismissed first. Once you've done editing individual elements, you can select them in hierarchy and group. Then toggle COL state and convert to compound. Note, element properties are applied to each component of the group, so in order to set a mass of such a collision element, you have to set mass on each item of the group (ZModeler will evaluate entire group mass as a sum of masses of group elements).


Physics properties.

Physics-specific properties of collision volumes are stored as User-defined options on collision elements. When collision object is compound, you have to toggle COL state prior to access or set user-defined options on such an object.

Mass property is the mass of an object in kilos.
E property is unknown 4 values set. I call it "Energy" or "Energy spread", but this could be something different. These values control element behavior in game including deformation level during impacts, and probably other in-game specific properties. In old implementation of GTA:IV filter, this property was evaluated on export depending on associated collision volume boundary. As a result, an in-game model suffer of inaccurate mesh deformation, and/on incorrect behavior of openable elements (like bonnet that drops off after a very small contact). In this filter I leave this property editable, so you can assign your own four values for component physics. You can observe original models and write down the most commonly used component-specific values to reproduce the same on your modded content.

You can make your own considerations and conclusions on these values. If you come up with some ideas, feel free to post on forum, we all could be able to sort this out together when we have more input and testing results.

Updates and changes log.
July 2016:
The following user-defined properties could be added onto COL object. If the COL object is a group of components, the property is added onto entire group (in contrast to "Mass" and "E" property that should be set on each group element).
Stamina user-defined property with four values in it. The first one is an object (component) stamina to user action; other three values are generally the same on most of objects: 100, 1000 and 0.25 (purpose is unknown)
Destroy user-defined property with a set of property bits ranging from 1 to 16 inclusive. Meanings of values are mostly unknown;
9 = Destroy with single gun shot;
11 = destroyed object disappears (applies to light bulbs and other glass objects);
Setting any "Destroy" value on COL object requires you to set non-zero second value in "Base" property of the root dummy node. For example, if you change buffalo2 doors "Destroy" mode to "9, 11", the original "Base" value 20 should be changed to "20, 4" (for drop-off components).
User avatar
Oleg
Site Admin
Posts: 11180
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: [Guide] GTA V: Physics and collisions

Post by Oleg »

Collision volume convexity is important

Collision object should be convex. ZModeler does not verify topology and allows you to export any collision volume shape, but it is like to be rejected by the game if topology is wrong. Even more, the game can reject related collisions of it detects problem. For example, game will reject chassis collision if any of door collisions is wrong. Below is an example of original GTA4 collision that will not work in GTA5 unless fixed appropriately (expand to see full image) :
collision_convexity_important.jpg
madga182
Beginner
Posts: 174
Joined: Thu Aug 13, 2015 5:48 am

Text Guide For All Your Rotation, Flags And Collision Values

Post by madga182 »

The values of the Rotations, Flags, mass and E ... Are to be used as a guide
adjust as necessary for different vehicle weights and sizes.

Thank you For reading and may your modding be fun

ENJOY



----------------------------Rotations Of Moving Parts-------------------------


Boot Rotation And Flags

RotZ 0,0
RotY 0,0
RotX -72,0
Flags E

Bonnet Rotation And Flags

RotZ 0,0
RotY 0,0
RotX 0,72
Flags E

Driver Door Rotation And Flags (Also Applies to Rear Driver Doors)

RotZ 0,0
RotY 0,72
RotX 0,0
Flags E

Passenger Door Rotation And Flags (Also Applies to Rear Passenger Doors)

RotZ 0,0
RotY -72,0
RotX 0,0
Flags E


------------------------------------------------------------------------------

-----------------------------Collision Values---------------------------------

**Doors**
Mass = 13.2156
E = 0.142806, 0.0273349, 0.11969, 0.0971182


**Chassis**
Mass = 745.993
E = 1.16226, 0.290771, 1.3179, 5.48211
E = 1.64477, 0.399181, 1.86934, 8.56036 (alternative)


**Boot**
Mass = 6
E = 0.0240694, 0.111959, 0.102861, 0.04297


**Bonnet**
Mass = 5
E = 0.110583, 0.0876393, 0.188284, 0.0340694


**windscreens**
Mass = 0.5
E = 0.0247546, 0.087055, 0.100528, 0.00301745


**Bumper**
Mass = 22.4
E = 0.0258687, 0.191657, 0.199956, 0.164763


**[Wheel_lf]**
Flags = AE
Mass = 14.57
E = 0.0405764, 0.0717447, 0.0405764, 0.107102

**Wheel_lr**
Flags = A
Mass = 21.5472
E = 0.0461546, 0.0717447, 0.0461546, 0.158345

**Wheel_rf**
Flags = A
Mass = 14.5741
E = 0.0405764, 0.0717447, 0.0405764, 0.107102

**Wheel_rr**
Flags = A
Mass = 21.5472
E = 0.0461546, 0.0717447, 0.0461546, 0.158345


Optionally Flags = E is recommended for bumpers and wings, so respective pats will drop off the vehicle at impact.
-------------------------------------------------------------------------------


This guide was created by Madgaz Gaming
http://www.youtube.com/Madgazgaming


ENJOY PLEASE DONT SELL OR COPY THIS WITHOUT CONCENT
User avatar
Ikey07
Posts: 17
Joined: Wed Feb 18, 2009 2:03 am

Re: [Guide] GTA V: Physics and collisions

Post by Ikey07 »

I can't find any information about how to make that player cant walk through vehicle doors when they are open, maybe someone can explain ?
User avatar
Oleg
Site Admin
Posts: 11180
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: [Guide] GTA V: Physics and collisions

Post by Oleg »

refine collision volumes. if still not work, untick "Deformable" in properties->mesh->vertices->format on problematic collision(s).
Delta4
Posts: 1
Joined: Tue May 10, 2016 3:04 am

Re: [Guide] GTA V: Physics and collisions

Post by Delta4 »

When I pull the handbrake the back wheels brake for a second and then continue spinning even though I'm still holding on to the handbrake, any ideas on how I could fix this?

This is what it looks like:
https://www.youtube.com/watch?v=83cyY7LrdNg
User avatar
Oleg
Site Admin
Posts: 11180
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: [Guide] GTA V: Physics and collisions

Post by Oleg »

Updates have been submitted. Check the very first post for details.
orielc
Posts: 9
Joined: Wed Sep 14, 2016 12:56 pm

Re: [Guide] GTA V: Physics and collisions

Post by orielc »

if I want to put mirrors instead of the wings which would be the values in "Mass" and "E".
User avatar
Oleg
Site Admin
Posts: 11180
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: [Guide] GTA V: Physics and collisions

Post by Oleg »

Keep E of original wing. Set mass of your choice.
Retrocop
Posts: 10
Joined: Wed Jan 03, 2018 9:58 am

Re: [Guide] GTA V: Physics and collisions

Post by Retrocop »

How choose flags on 3.2.0 version? How atributes will fit to old flags?
Кажется в новой сборке с этим вообще какой-то баг. Даже сохранить опции для GTA V не получается. Сохраняешь, уходишь на уровень объекта, возвращаешься, атрибуты не выставлены.
User avatar
Oleg
Site Admin
Posts: 11180
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: [Guide] GTA V: Physics and collisions

Post by Oleg »

what exactly does not work? flags and IDs are no longer used explicitly, their "meaningful" representation is given.
col_flags.jpg
Retrocop
Posts: 10
Joined: Wed Jan 03, 2018 9:58 am

Re: [Guide] GTA V: Physics and collisions

Post by Retrocop »

всё получилось, как выяснилось я неправильно импортировал модель. Спасибо за ответ!
emtp211
Posts: 54
Joined: Sat Sep 30, 2017 6:32 am

Re: [Guide] GTA V: Physics and collisions

Post by emtp211 »

having trouble with my collisions being walk through and the tires collisions going through the ground and bottoming out the vehicle. and i cant find deformable option where is it ?

ive redone the collisions several times from default collision, worked early in testing now no more. imported the ytf with no issues can i get some help ?


https://i.gyazo.com/622ebd7a9b57bce8bfa ... 5a6c71.png
Last edited by emtp211 on Fri Aug 03, 2018 3:07 am, edited 1 time in total.
User avatar
Oleg
Site Admin
Posts: 11180
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: [Guide] GTA V: Physics and collisions

Post by Oleg »

i see a lot of axes spread around your vehicle. in most of cases local axes on COL objects should be "centered to object" (display->local axes->center to object). "deformable" option is properties branch for geometry object: Properties->mesh->vertices->format->deformable. (select geometry COL object and change this option).

in most of cases, vehicle's COL object should have this option toggled on. Also, when you press "Damage" button on Structure panel, all deformable COL objects should get a bit smaller, but should still retain the overal shape. You should import any original game vehicle and take a look on original COLs setup and behavior.
emtp211
Posts: 54
Joined: Sat Sep 30, 2017 6:32 am

Re: [Guide] GTA V: Physics and collisions

Post by emtp211 »

thanks will fix that just noticed it
emtp211
Posts: 54
Joined: Sat Sep 30, 2017 6:32 am

Re: [Guide] GTA V: Physics and collisions

Post by emtp211 »

https://i.gyazo.com/57ab4941182e2c8995d ... b05baa.png

so far, silly question to view deformable mode must i be in object mode and slect the COL mesh ? cause i dont see it


so in game the col acting funky, act as if the collison is 2 feet in front of the vehicle

https://gyazo.com/ad5a9eb428c8b05cd2e36368c26c1ac4

collisions also work when you fix something but you can walk through them.

im told to import a new ytf and try again ?
emtp211
Posts: 54
Joined: Sat Sep 30, 2017 6:32 am

Re: [Guide] GTA V: Physics and collisions

Post by emtp211 »

https://i.gyazo.com/622e0b018af513b9a58 ... 7194e6.png

so when i import the ytf back in i get this,

question how do i get it to stop moving the colision?
User avatar
Oleg
Site Admin
Posts: 11180
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: [Guide] GTA V: Physics and collisions

Post by Oleg »

I would recommend to reset collision local axes to their parent objects (display\local axes\reset to parent). but first of all, ensure associated parent objects (parts) have correct axes locations. Also, If i'm not mistaken, "chassis" object and its COL need local axes to be at 0,0,0 point (display\local axes\reset to world).
botanuim
Posts: 6
Joined: Fri Aug 09, 2019 4:04 am

Re: [Guide] GTA V: Physics and collisions

Post by botanuim »

Is there a way or flag to make an object solid, so PED when they get a hit don't fall, or don't fall also when it get shoot
Last edited by botanuim on Sat Aug 10, 2019 4:22 am, edited 1 time in total.
User avatar
Oleg
Site Admin
Posts: 11180
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: [Guide] GTA V: Physics and collisions

Post by Oleg »

ped physics is outside of .yft/.ydd files. I assume it is configured in some metadata files. Your question is related to the ped physics data rather than to the model itself.
botanuim
Posts: 6
Joined: Fri Aug 09, 2019 4:04 am

Re: [Guide] GTA V: Physics and collisions

Post by botanuim »

So you mean like lamppost physics are stored in another files? Like destruction etc...
User avatar
Oleg
Site Admin
Posts: 11180
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: [Guide] GTA V: Physics and collisions

Post by Oleg »

Lampposts are destructible/fragmentible models (.yft files) and store collisions inside. Other props that are not static (.ydr files) do have collision inside too. I assume your question was about physics of ped model? Ped model is made of skeleton (.yft) and visual components (.ydd). The rest is configured in metadata file as I know. I assume body parts physics is there too.
botanuim
Posts: 6
Joined: Fri Aug 09, 2019 4:04 am

Re: [Guide] GTA V: Physics and collisions

Post by botanuim »

No ,not about peds, I'm making a lamppost and done collision and proper flags ( metal etc...) but when a PED walk to it it fall, I want make my lamppost like V one so it get destroyed when get hit by car/grenade

Sorry for my bad English
Last edited by botanuim on Sun Aug 11, 2019 8:48 am, edited 1 time in total.
User avatar
Oleg
Site Admin
Posts: 11180
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: [Guide] GTA V: Physics and collisions

Post by Oleg »

is your model .yft or .ydr? how your collision object look like? Is it a mesh geometry or dummy primitives (capsules, boxes ?)
have you tried to attach original lamppost collision to your model for test purpose?

I remind I was messing with street light pole while editing lights and got some collision problems. But they were related to an immediate destruction response of the object even when ped/player touches the light pole walking nearby. The pole did not fall through the ground, but got destroyed instantly.
botanuim
Posts: 6
Joined: Fri Aug 09, 2019 4:04 am

Re: [Guide] GTA V: Physics and collisions

Post by botanuim »

It's an yft, also noticed V colls are different to one's I did also
I had different situations :
One when it move but don't get destroyed
Other one destroy perfectly like V ones but also it do this when peds walk to it
Also noticed after respawn , lights won't work
Also it's a geometry
Post Reply