Custom Soldier Collision Tutorial

How to create models in XSI and other 3D applications and make them work in Battlefront 1 & 2. Post models, tips for application usage and share anything XSI, 3DMax, SketchUp, etc.

Moderator: Moderators

MileHighGuy
Jedi
Jedi
Posts: 1194
Joined: Fri Dec 19, 2008 7:58 pm

Custom Soldier Collision Tutorial

Post by MileHighGuy »

I just made a big discovery.

I found out how to define custom soldier collision for your models!

Proof

http://imgur.com/a/D9xX9
Hidden/Spoiler:
Image
Image
(yes it is real, the ai even targeted the tiny primitive that I made for ordnance collision)

It is a very easy process.

1. Load your unit model into xsi. It should have the bone_root as it's child.

2. Add collision primitives. I would make a primitive (a large cylinder type) for vehicles, terrain, and buildings as the child of the dummyroot. To make collision primitives for specific parts of the skeleton, make it the child of the desired bone. For perfect collision, make sure each bone has a primitive (e.g. collision for the left thigh bone make a primitive as the child of bone_l_thigh). When you are done hide all the primitives by selecting them and pressing "h".

They follow the same rules as any other collision primitive:
Hidden/Spoiler:
[quote]Collision Primitives

--- Collision Primitives are a cheaper and faster way of computing collision for the game engine.
It is also the only way to have collision on moving parts such as turrets or bones.
Collision primitives can be either cubes, cylinders, or spheres.
Cubes can be scaled in x,y, and/or z to better fit the geometry they are conforming to.
It is best to leave the original size of 8 units as is and scale the cube from there.
On the other hand, cylinders and spheres CANNOT be scaled. Instead, use the polygon properties such as Radius and Length to control the size of those 2 primitives.
Whether you use cubes, cylinder or spheres you'll want to keep the default Subdivisions.
Also very important, primitive collision pieces CANNOT be frozen(Freeze or Freeze M) or lose their primitive properties.
This information is taken directly into the game engine and if it is lost, the engine will most likely ignore the primitive collision.
Lastly, DO NOT move the center or Freeze the Transforms of primitive collision either or else the proper information will be lost as well.
---There is a limit of 64 collision primitives per model (or 63 primitives + 1 collision mesh).


NEW BFII UPDATE FOR COLLISION AND USING PRIMITIVES

The game now supports the use of new naming conventions in XSI – no more ODF magic required!

The old naming conventions are still valid – naming primitives "p_name" and mesh "collision_name" - but if you use these you still need to do soldier/vehicle/etc separation the old way through ODFs. Nothing old will break, but there’s no reason to do anything new using ODF definitions. 

New names:

Primitives –   p_-xxx-name     ---    ("p" underscore hyphen [types] hyphen name)

Mesh –     collision_-xxx-name    ---    ("collision" underscore hyphen [types] hyphen name)

xxx is replaced with the type definitions below…

[Types] is any combination of the following:

s – Soldier (soft) collision

v – Vehicle (rigid) collision

b – Building (static) collision

o – Ordnance (ordnance :^) collision

t – Terrain collision

f -- Flag collison -used on flyers specifically for Space CTF to collide with the flag 


So if you made a cube and wanted it to be used for soldier and vehicle collision, you’d name it
"p_-sv-SomeName"

Or if you wanted it to be used for ordnance collision only, you’d name it

"p_-o-SomeName"

Typicly ordnance collision needs to be more accurate so you could make a mesh and, you’d name it

"collision_-o-SomeName"[/quote]

ZETools allows you to skip step 3. You must have the primitive type name included in the name, so for example a cube that would be collision for terrain only would be called p_-t-cube(_name optional). Without this you must do step 3.

3. (optional) Add a custom parameter under each primitive. Select the collision primitive in the explorer and then go to Animate > Parameter > New Custom Parameter (or press Shift+P). For the parameter name, use "type". I made the value range from 0 to 10. Press OK. Then rename the parameter to "collprim". The "type" slider should be set to 2 for cylinders, 0 for spheres, and 4 for cubes.

4. Now you are done with the modeling part of it. Export like you would any other unit (I used ZETools).

5. In your unit's odf add the line IsAcklay = 1. This tells the game to use your custom primitives. Without any primitives your unit will just fall through everything.

6. (optional) To define your critical hit location, add the line HitLocation = "p_-so-head 4.0" (this is an example, use your own primitive's name).
Hidden/Spoiler:
[quote]HitLocation – The location of its critical hit point. The number at the end determines its multiplier. For instance, the “4” means this location causes 4x the normal damage[/quote]
This also means you can add shields. Yes, shields! just make the modifier less than 1 and you have a functional shield. 0 takes no damage at all! So now you can have area specific damage! Perfect for a medieval mod. The crosshair will not display a critical hit unless the multiplier is more than 1. a multiplier of 0 means no damage marker at all!

7. In your map's lua, add the line SetMemoryPoolSize("AcklayData", 20) next to the other Set MemoryPool lines. I assume it has to be set to a number the same as (or greater than) the number of units with custom collision.

8. That's It!

Theoretically, This should allow for units of any size and shape *coughdinosaurscough*. No longer are you restricted to that dumb 2 sphere pre-defined collision. Enjoy!
Last edited by MileHighGuy on Sun May 03, 2015 3:33 am, edited 21 times in total.
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: Custom Soldier Collision Tutorial

Post by Marth8880 »

Yes! Now the Praetorians and Scions won't be quite as horrible in my mod! :o Thanks a lot for discovering this! :thumbs:
JimmyAngler
High General
High General
Posts: 837
Joined: Mon Nov 04, 2013 10:37 am
Projects :: Battlefront Halation
Games I'm Playing :: SWBF 1-2-2015
xbox live or psn: none
Location: Area 51

Re: Custom Soldier Collision Tutorial

Post by JimmyAngler »

WoooHooo! This belongs in the faq. Thanks MileHigh!
MileHighGuy
Jedi
Jedi
Posts: 1194
Joined: Fri Dec 19, 2008 7:58 pm

Re: Custom Soldier Collision Tutorial

Post by MileHighGuy »

Thanks guys :D

So IsAcklay = 1 also makes it so the units don't jump around like maniacs, they don't roll, crouch, or sprint on their own. They still sprint when following you. This is totally fine by me and is in fact preferred. So you wont have to worry about having your dinosaur jumping all the time and rolling away from grenades.

EDIT: The above statement is wrong. When given a gun, the collision still works and they seem to behave like normal units. With a sabre, they don't jump on their own.

I think they still will jump or crouch with hint nodes, because the acklay odf has IgnoreHintNodes = 1 in it, which makes me think it is separate.

With the prone animation the collision is fine but the origin of the ordnance is the same as crouching.

EDIT: Wow, I put terrain collision on only his feet and got real walking! When I rolled his body sunk into the ground because it did not collide with the terrain!
Last edited by MileHighGuy on Thu Jul 24, 2014 9:31 am, edited 4 times in total.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Custom Soldier Collision Tutorial [update- shields! ]

Post by Maveritchell »

Really clever how you worked that out. Nice work!
User avatar
The Nasal Abyss
1st Lieutenant
1st Lieutenant
Posts: 428
Joined: Sun Sep 14, 2008 12:55 pm
Projects :: Currently Working on an Indie Game
Games I'm Playing :: Splatoon 2
xbox live or psn: Stm: Tight Verbage

Re: Custom Soldier Collision Tutorial [update- shields! ]

Post by The Nasal Abyss »

Very, very awesome. This possibilities and uses of this.........
User avatar
AceMastermind
Gametoast Staff
Gametoast Staff
Posts: 3284
Joined: Mon Aug 21, 2006 6:23 am
Contact:

Re: Custom Soldier Collision Tutorial [update- shields! ]

Post by AceMastermind »

3. Add a custom parameter under each primitive. Select the collision primitive in the explorer and then go to Animate > Parameter > New Custom Parameter (or press Shift+P). For the parameter name, use "type". I made the value range from 0 to 10. Press OK. Then rename the parameter to "collprim". The "type" slider should be set to 2 for cylinders, 0 for spheres, and I assume 1 for cubes. EDIT: So far, I have not been able to get cubes to work. Only spheres and cylinders.
I'm pretty sure you can skip this step.
User avatar
ANDEWEGET
Ancient Force
Ancient Force
Posts: 1266
Joined: Tue Apr 01, 2008 8:42 am
Location: Germany
Contact:

Re: Custom Soldier Collision Tutorial [update- shields! ]

Post by ANDEWEGET »

Likely. Cube type primitives would also be 4, not 1.
MileHighGuy
Jedi
Jedi
Posts: 1194
Joined: Fri Dec 19, 2008 7:58 pm

Re: Custom Soldier Collision Tutorial [update- shields! ]

Post by MileHighGuy »

Actually, you can't. I just tested it again to make sure. And thanks ANDE, updated first post.
User avatar
ANDEWEGET
Ancient Force
Ancient Force
Posts: 1266
Joined: Tue Apr 01, 2008 8:42 am
Location: Germany
Contact:

Re: Custom Soldier Collision Tutorial

Post by ANDEWEGET »

You can skip it if you follow ZE Tools collision primitive naming conventions. p_ + "cube" for cubes, "cyl" for cylinders and "sphere" for spheres.
Examples: "p_cube_01", "p_cyl_barrel".

The way you do it is actually used for importing collision primitives because of course most meshes don't follow those conventions. That's also why there's no easy way/tool to add that property.
MileHighGuy
Jedi
Jedi
Posts: 1194
Joined: Fri Dec 19, 2008 7:58 pm

Re: Custom Soldier Collision Tutorial

Post by MileHighGuy »

I just tested it again, you're right. You have to name it p_-so-cube(_name optional). Without the cube in the name you have to use custom paramters. First post updated.

EDIT: you guys are gonna like this:
Hidden/Spoiler:
Image
I'd really like to make the walking up hills normal again, but so far only a really large sphere has almost worked, and it was really buggy too. Anyone got any ideas? This kinda ruins the idea for bipeds using this.
User avatar
The Nasal Abyss
1st Lieutenant
1st Lieutenant
Posts: 428
Joined: Sun Sep 14, 2008 12:55 pm
Projects :: Currently Working on an Indie Game
Games I'm Playing :: Splatoon 2
xbox live or psn: Stm: Tight Verbage

Re: Custom Soldier Collision Tutorial [last post edited]

Post by The Nasal Abyss »

I'd imagine its a sideeffect of using IsAcklay = 1. The acklay have that exact collision behavior. Its probably hard coded if I were to guess.
MileHighGuy
Jedi
Jedi
Posts: 1194
Joined: Fri Dec 19, 2008 7:58 pm

Re: Custom Soldier Collision Tutorial [last post edited]

Post by MileHighGuy »

Yeah, I figured. I just thought there would be a primitive I could use as terrain collision to stop this.
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am
Games I'm Playing :: SWBF2
Location: Princeton, NJ

Re: Custom Soldier Collision Tutorial [last post edited]

Post by razac920 »

So I'm trying to follow this tutorial to import a famba unit from BF1, but I have no experience with modeling and it still seems be missing collision geometry in game.

Here's a link to the BF1 .msh that I had originally hexeditted to make the texture transparent (in order to hide the shield generator), and the 2.msh is what I just exported out of XSI Mod Tool. It actually came with collision primitives, so I just deleted the two collision primitives that corresponded to the shield generator, renamed all the others to match the BF2 system, and exported. However, I don't see any change in the collision geometry in game (bullets still go right through it).
User avatar
AceMastermind
Gametoast Staff
Gametoast Staff
Posts: 3284
Joined: Mon Aug 21, 2006 6:23 am
Contact:

Re: Custom Soldier Collision Tutorial [last post edited]

Post by AceMastermind »

You must follow the exporting rules based on your method and toolset.
nab1_walk_fambaa2.msh says you used ZETools to export it, therefore you must use the naming convention ANDE wants for exporting primitive collision with ZETools.

Your:
p_-svbo-cyl_collision12
would be:
p_-svbo-cylinder_xxxx12
(if you were to keep it the same length)

SWBF2 really only cares about this part for the new naming convention:
p_-[types]
after that you can put an underscore and whatever text you want, though i'm sure there has to be a character limit.
If I was exporting with the Pandemic Tools I would just do this:
p_-[types]_somename

While you have the Fambaa in XSI you could easily remove unneeded geometry.
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am
Games I'm Playing :: SWBF2
Location: Princeton, NJ

Re: Custom Soldier Collision Tutorial [last post edited]

Post by razac920 »

Okay, I changed all the names to match the format, and also shortened them, but for some reason I am only seeing collisions on the lower legs (#4, 6, 7, 12).

https://dl.dropboxusercontent.com/u/852 ... ambaa2.msh

Wait a sec, the names of the primitive collisions has to stay the same length as when they were made?
User avatar
AceMastermind
Gametoast Staff
Gametoast Staff
Posts: 3284
Joined: Mon Aug 21, 2006 6:23 am
Contact:

Re: Custom Soldier Collision Tutorial [last post edited]

Post by AceMastermind »

Error (404)
razac920 wrote:Wait a sec, the names of the primitive collisions has to stay the same length as when they were made?
No, only if you'd rather hex edit the names instead of exporting the scene again, but ZETools needs the right naming convention on export so it knows how to handle the objects.
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am
Games I'm Playing :: SWBF2
Location: Princeton, NJ

Re: Custom Soldier Collision Tutorial [last post edited]

Post by razac920 »

I'm not getting any error downloading, are you sure you didn't copy the abbreviated link into the URL box by mistake?
User avatar
AceMastermind
Gametoast Staff
Gametoast Staff
Posts: 3284
Joined: Mon Aug 21, 2006 6:23 am
Contact:

Re: Custom Soldier Collision Tutorial [last post edited]

Post by AceMastermind »

No I didn't copy anything, just clicked on your link. It works now though.
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am
Games I'm Playing :: SWBF2
Location: Princeton, NJ

Re: Custom Soldier Collision Tutorial [last post edited]

Post by razac920 »

Oh okay, maybe it took a little while to upload? I'm not sure.

Another strange thing: when I go to look at the collision geometry in game with the console command, it does appear correctly, but I have to be pointing the cursor at the legs of it for it to appear (other models pointing anywhere on them gets the display to show).

EDIT: So I'm thinking that the .msh file is not the problem. When I comment out the SkeletonName from the unit's .odf file, the collisions work correctly. And same for the unmodified nab1_walk_fambaa.msh file. Any idea what in an animation bank could break custom soldier collisions?
Last edited by razac920 on Fri Apr 17, 2015 12:50 am, edited 1 time in total.
Post Reply