Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Collision group tutorial/reference (including naval/amphibious/hover units)
Collision group tutorial/reference (including naval/amphibious/hover units) [message #486392] Mon, 24 February 2014 17:08 Go to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

Every physics object in Renegade has a collision group type that describes which other collision types it can collide with.

Note that this has nothing to do with the rendering engine collision settings (physical, projectile, vis, camera, vehicle) that you set in gmax/3ds max

Scripts 4.x adds a number of new collision group types for various features including boats, subs, hover units, amphibious units and underground units.
The full list of collision types (and the in-game numbers that represent them) is:

  • Default = 0
  • Uncollideable = 1
  • Terrain Only = 2
  • Bullet = 3
  • Terrain and Bullet = 4
  • Bullet Only = 5
  • Soldier = 6
  • Soldier Ghost = 7
  • C4 = 8
  • Underground = 9
  • Soldier Only = 10
  • Soldier Bullet = 11
  • Terrain = 15
  • Water Surface = 16
  • Water Edge Block = 17
  • Water Edge Allow = 18
  • Beach Edge = 19
  • Naval Unit = 20
  • Beaching Unit = 21
  • Hover Unit = 22
  • Amphibious Unit = 23
  • Amphibious Unit Floor = 24


This image
http://www.tiberiantechnologies.org/wiki/images/4/4b/Collision_group_reference_dark.png
shows what collision types each collision type can collide with.

Note that you can put any collision type on any object e.g. you aren't restricted to using C4 on just C4 objects. The names just indicate their intended purpose.

Terrain always has a collision type of "Terrain". Tiles by default have a collision type of "Terrain" by default but can be changed using the drop-down list in leveledit.

Objects (i.e. the stuff under "object" in leveledit) can have the script SH_CustomCollisionGroup added that will let you set the collision group using the numbers in the list above.

By default beacons will have a collision group type of "Terrain and Bullet", C4 will have a collision group type of "C4", Cinematic objects will have a collision group type of "Terrain", Powerups will have a collision group type of "Terrain" or possibly "Uncollideable" (I cant tell from the code which it is, seems to depend on whether its pre-placed in LE or spawned by a script/spawner), Special Effects objects will have a collision group type of "Uncollideable".

Soldiers can have various collision groups at runtime depending on their state so using SH_CustomCollisionGroup on a soldier object will not work.

For programmers you can look at the source code of SH_CustomCollisionGroup and the enum in physdefclass.h to see how to set collision group programmatically.

The Disable_All_Collisions script command sets the objects group type to "Uncollideable". The Disable_Physical_Collisions script command sets the objects group type to "Bullet Only" and the Enable_All_Collisions script command sets soldier objects to "Soldier" and all other objects to "Default"

Coming up in part 2, a guide to how to use the collision stuff to implement naval logic as seen in Red Alert: A Path Beyond (boats, subs and LSTs) and how to use it to implement units similar to the Amphibious APC and Hover MRLS in Tiberian Sun Reborn


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies

[Updated on: Tue, 25 February 2014 00:35]

Report message to a moderator

Re: Collision group tutorial/reference [message #486394 is a reply to message #486392] Mon, 24 February 2014 18:37 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

One small addition:
All objects not otherwise mentioned get collision type "default"


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Collision group tutorial/reference [message #486395 is a reply to message #486392] Tue, 25 February 2014 00:34 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

The next part will describe how things are set up for amphibious and hover units in Tiberian Sun Reborn.

Firstly, you need to create the vehicles.
The only special thing you need for the amphibious unit (which is designed to be unit that drives along the ground but appears to be "floating" when in the water) is a copy of SH_CustomCollisionGroup on the vehicle with the value set to 23 (aka "Amphibious Unit")
For hover units (which is for anything designed to travel on top of water and "hover"), you need a copy of SH_CustomCollisionGroup on the vehicle with the value set to 22 (aka "hover unit"). You will probably also want to make the wheel bones and such of your vehicle invisible so it appears to be hovering (The Hover MRLS in Reborn is set up as a tracked vehicle which seems to work best for hover vehicles rather than a wheeled vehicle)

Next up you need special geometry on the map to make things work correctly. Firstly create a mesh (in a separate w3d file from the main terrain) for the "water surface" (this is what hover units will drive on top of). This shouldn't be the actual water surface with the texturing on it. It should have flags set to "hidden" and "physical collision" and nothing else.

Export this as "terrain" in gmax/max. Create a tile in leveledit and assign this mesh. It needs to be StaticPhys and needs to have IsNonOccluder ticked, Collision Group set to "water surface" and "visibility mode" left at "default"

Then place your tile on the map like you would with any other tile.

Next up you need to create another similar mesh for the "Amphibious Unit Floor". This is what the amphibious unit will drive on when in the water (so it should be placed such that the vehicle appears to be floating on the water surface when its driving on it) It should be created just like the "Water Surface" mesh above with the same flags and settings except that it should have Collision Group set to "amphibious unit floor".

That concludes the section of the tutorial on hover and amphibious units.
Coming up next is information building on this that describes how to set up boats, submarines and naval transports.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Collision group tutorial/reference (including naval/amphibious/hover units) [message #486397 is a reply to message #486392] Tue, 25 February 2014 03:29 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

Note that it is the size/position of the worldbox (which for vehicles has Physical collision ticked), not the geometry itself (which doesn't have Physical collision ticked) that determines how low or high the vehicle rides.

For example, the Reborn Amphibious APC has a larger worldbox with more worldbox underneath the vehicle than usual so that when it drives on the "amphibious unit floor" it will achieve the desired height so it appears to be floating on the top of the water.

The boats in APB (including the naval transport) have part of their structure (the nit that is underwater) sticking out from below their worldboxes so that when they ride on the "water surface" mesh, part of the geometry sits underneath the water.

The submarines in APB have any part that is visible above the water when its surfaced to be protruding above the worldbox (as the water surface will act as a "lid" and keep the worldbox from moving past it)


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies

[Updated on: Tue, 25 February 2014 03:36]

Report message to a moderator

Re: Collision group tutorial/reference (including naval/amphibious/hover units) [message #486398 is a reply to message #486392] Tue, 25 February 2014 04:00 Go to previous message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

Ok, now for the tutorial on naval units. Other than the aforementioned worldbox changes, they are just like any other vehicle. The boats (including naval transports) are set up as tracked vehicles (with invisible wheels). The submarines need to be set up as VTOL vehicles so the can move up and down in the water. The only other setting required is to set the "type" as appropriate (either Boat or Sub depending on what you are making). Everything else is as normal for vehicles.

As for scripts, both boats and subs require SH_CustomCollisionGroup with a setting of 20 aka "naval unit".
Units that can come onto the beach but not onto land more generally (i.e. naval transports) need a setting of 21 aka "beaching unit".

For the water surface in the naval logic, you need to make the actual visible water surface a separate mesh. You need 2 meshes, one facing up for the top surface (which will dictate how low into the water boats will go) and one facing down for the bottom surface (which will dictate how high up subs will go) and is what people in submarines see when they are underwater. They need "physical" collision ticked and nothing else (technically they dont need to be 2 separate meshes but the example I am working from has them as 2 separate meshes). Export this as terrain. In leveledit, you need to make this as a tile with StaticPhys, "IsNonOccluder" ticked, "water surface" collision and "default" visibility mode and place it in your level.

Next up, you need a blocker around the edge of the water (this will limit where naval vehicles can go). This should also be "physical" collision only and should be hidden so it cant be seen. In-game, its the same as the water surface (StaticPhys etc) except that it needs either collision group "water edge (allow)" (if you want to allow soldiers and normal vehicles into the water) or "water edge (block)" (if you want to block soldiers and normal vehicles from entering the water).

Finally, if you have any vehicles with "beaching unit" set on them, you need another blocker further in (just like the water edge) with "beach edge" collision group.

This concludes the tutorial on collision detection and how to use it to build boats, submarines, naval transports, amphibious units and hover units.

Anyone with questions on all this stuff (or if you are having problems getting it working), feel free to post here or hit me up on IRC/IM.

A tutorial for Naval Factories is on my todo list and will be done soon.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Previous Topic: Team Collision
Next Topic: 2 changes to leveledit made in 4.1
Goto Forum:
  


Current Time: Wed Dec 18 01:00:27 MST 2024

Total time taken to generate the page: 0.00649 seconds