How do we do basic collisions?

Ask questions, discuss ideas, get answers
User avatar
Summer
Posts: 16
Joined: Thu Nov 14, 2013 7:35 am

How do we do basic collisions?

Post by Summer »

So far I've learned how to import a crate with a texture I downloaded from google and a mesh I made in GMAX. I've got it working in Battlecraft and BF1942 and now I want to add some awesome collision detection for it.

How do I add collision detection so when I walk into the crate it will prevent me from walking through it.

I made a youtube video for more details =D



Btw, I've tried hitting up google but couldnt find much about this and plus I'm generally lost how it all works.
Image
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: How do we do basic collisions?

Post by Swaffy »

Import a box already in BF1942 and look at it. Also note the naming conventions used.
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
User avatar
Summer
Posts: 16
Joined: Thu Nov 14, 2013 7:35 am

Re: How do we do basic collisions?

Post by Summer »

I've studied the ammo box but cannot see the link between the collision meshs and the game engine. Are the name conventions critical? Is there some hidden voodoo looking for those names?
Image
User avatar
BotHunter
Posts: 480
Joined: Thu Jan 10, 2013 11:22 pm
Contact:

Re: How do we do basic collisions?

Post by BotHunter »

Summer wrote:I've studied the ammo box but cannot see the link between the collision meshs and the game engine. Are the name conventions critical? Is there some hidden voodoo looking for those names?
Lol. not really. when you export the mesh, you are using the "add lod" button. to the right of it, this are "col1" and "col2" buttons. these are the collision mesh buttons. you export a mesh as the collision mesh to interact with other objects.
Walk quietly and carry a sniper rifle
User avatar
Summer
Posts: 16
Joined: Thu Nov 14, 2013 7:35 am

Re: How do we do basic collisions?

Post by Summer »

I tried that though, in the the youtube video you'll see that I have applied the mesh to the high and low collision mesh fields. Maybe I might try duplicating the mesh and using a seperate mesh for the collision detection.
User avatar
Summer
Posts: 16
Joined: Thu Nov 14, 2013 7:35 am

Re: How do we do basic collisions?

Post by Summer »

This is what I have in GMAX

Image

and in BGA it shows the collision mesh.

Image

And this is my Object file

Image
Image
User avatar
BotHunter
Posts: 480
Joined: Thu Jan 10, 2013 11:22 pm
Contact:

Re: How do we do basic collisions?

Post by BotHunter »

Hmm. in BGA it shows you only have COL1 set. soldiers use COL2. maybe that's the problem.
Walk quietly and carry a sniper rifle
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: How do we do basic collisions?

Post by Swaffy »

Again, open an object from the vanilla game and look at the objects' naming convention. In other words, look at how they named the objects. bbox is a bounding box; COL01 and COL02 are collision meshes; you might see a shadow mesh, then of course LOD01 is your visible model.

Name them correctly before trying to export, and use "Use object names for export" option. Also, set the number of LODs to 6. For a simple box you can use 3, just make sure the code for making the StandardMesh shows 3 instead of 6.
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: How do we do basic collisions?

Post by Apache Thunder »

I see you have not used the force material id check box. You will likely run into issues if you export with default materials on your collision mesh. (which in the case of bf1942 happens to be the material used by water. This material has collision bugs if used on meshes)

If your crate is "wooden", you can just use material 80 for default wood, or 82 for thin wood. Just type them into the material field once you have that check box ticked. (the drop down menu for this has no real purpose at this point since the script maker didn't put anything in it other then the single "Generic Armor" option)

From the screen shot you have the collision mesh filled in as well as the lod mesh. (I'd also recommend you tick the "BSP Optimization" check box. Probably not a big deal for a simple object like this, but using this for more complex objects is a must for good performance). From that screenshot of the export dialog, you have the minimum stuff set correctly, so the reason collision isn't working is not with the mesh, but with the coding and/or RFA it's packed in.

Also, COL02 is not required. If there is no COL02 the game will just use COL01 for all collisions. Generally COL02 are more important for vehicles and large statics. For example Planes collide with COL01 while land vehicles collide with COL02. If you made a large hanger building and your COL01 doesn't have an interior designed into it, you will find it impossible to get your planes into the building. COL02 is used by projectiles and soldier interaction as well. I also noticed child objects of any vehicle use COL01 for collision when hitting another vehicle. But that's getting into the itty bitty details that isn't important at this stage of modding right now.

I think the issue is perhaps in the coding. Did you check to see if there is an existing object that already uses the name you chose for your object? If so that would present a conflict and the game will ignore the new object and continue to use the old one. Generally the collision physics command is specified after the geometry command, though I don't see how the order of these two particular commands being important in this case. I'm just going by how I see 99.9% of all object code I've come across. :P

Code: Select all

ObjectTemplate.create SimpleObject crate
ObjectTemplate.geometry crate
ObjectTemplate.hasCollisionPhysics 1
There's not much else to add so I think there's either a problem with the materials your collision mesh is using or you haven't repacked the standardMesh rfa and it's still using the old one.

EDIT: After watching the video you appear to have used the lod mesh for your collision mesh on export. You definitely need to check the "Force MatID" option and set a material number. LOD Meshes almost always use material 1 for single material objects and so on, and that means you end up with the water material on your box. This mostly impacts vehicle collision as vehicle collision with objects that have material 1 assigned will have collision bugs and/or take excessive damage from even slow speed impact into the object. Though in this case it's not causing your issue since soldiers collide fine with objects that have the water material assigned. Though if you were standing on top of the box you would notice that you can't jump. That's another glitch with having a water material on a object. :P

This is a mapside mod so everything for your object is in the map rfa. Since your using Battlecraft, there's a possibility the editor is screwing up something with your object. Try placing some of the crates on your map, then extract and check everything to see that it's intact then repack the rfa with something like WinRFA or another similar tool. If it then works, then Battlecraft is messing up your object map somehow and causing the collision for the object to not work. I've checked the con files for vanilla BF1942 and there isn't another object with the name you chose, so there isn't a name conflict. So most likely something is getting corrupted when you are saving the map because from your screenshots and video, you are exporting the mesh correctly and the code you wanted to use should have worked.
ImageImageImage
I have cameras in your head!
User avatar
Summer
Posts: 16
Joined: Thu Nov 14, 2013 7:35 am

Re: How do we do basic collisions?

Post by Summer »

Thanks guys! I'm pretty sure it ended up being some other files in standardMesh.rfa named crate, overriding any custom ones I added to my map.

I made up some youtube videos while I was trying to figure it out



Image
Post Reply