Some interesting things achieved with c_CGStaticObjects

Ask questions, discuss ideas, get answers
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Some interesting things achieved with c_CGStaticObjects

Post by Apache Thunder »

A while back I noticed there are two collision groups for the addToCollisionGroup command that are not used. The one I was interested in was c_CGStaticObjects, which at first didn't seem to work like I thought it did. (the other being c_CGLandscape which causes any object that has it to pass through the terrain. The terrain seems to already have the CGLandScape collision group by default, thus explains why this works when adding it to a test object)



Initially I thought it would cause a object its used on to pass through all static objects. But this is not in fact what happens. I added it to a vehicle, but it did not pass through any staticobjects.


This collision group is completely unused by anything. Since I was aware that other collision groups are part of objects by default like with projectiles, I realized that this one isn't assigned to any object and by default no object is using this collision group, which explains why adding it to a object will not allow it to pass through static objects. Because all those said objects are not added to this collision group. The command must be specified and that collision group must be assigned to it and any other objects you want them to "not" interact with.


This means that some interesting things can be done with this since nothing is using it, no ill effects will occur from using it in a mod.

The best use I've come up with is selective projectile penetration. The trick is to add a projectile to the c_CGStaticObjects collision group. Then any other object that is using this collision group, it will not collide with. Thus passing through it as if it's not there.

This is NOT the same as the effect achieved via adding a static object like a fence to the c_CGProjectiles collision group. Because ALL projectiles by default are in this collision group, that means it would allow ALL projectiles to pass through it. (this would likely be the reason why it's never possible to have two projectiles collide with each other, they are both in the same collision group and this is not avoidable and we know there is no such thing as "removeFromCollisionGroup" command. :P )

However the c_CGStaticObjects collision isn't used by anything by default, thus you can use this collision group to achieve some interesting results. For example you can add a vehicle to this collision group, then create a special gate or other similar thing that only allows that said vehicle to pass through it. (keep in mind you need to add ANY solid child object of the host vehicle to the collision group as well since adding it to only the main PCO is not enough. All child objects with collision physics would need it as well).

This could be used on fences/walls to allow certain projectiles to pass through but prevent others from passing through. Or for allowing vehicles to pass through but not others. (note that this doesn't seem to work on soldiers correctly. They seem to lose the collision group setting after entering a vehicle. Thus if you enter a vehicle, then exit it, you are not longer in the staticObjects collision group. Vehicles can't enter other vehicles, thus they won't have this problem. :P )

The best example I can think of is "Bunker Buster" type weapons. This projectile will pass through a bunker that has been added to this collision group. Because no other projectiles are on this collision group, only the bunker buster will pass through it while everything else will collide with it like normal.

Example of how to achieve this. It's pretty simple actually. :D

Code: Select all


ObjectTemplate.create Projectile BunkerBuster
ObjectTemplate.addToCollisionGroup c_CGStaticObjects

Then add this to any bunkers you have:

Code: Select all

ObjectTemplate.create SimpleObject ExampleBunker
ObjectTemplate.addToCollisionGroup c_CGStaticObjects
If your bunker has multiple floors, you will need to decide how far you want the bunker buster to pass through before it hits something. You can split the top and bottom floors into child objects and have the bottom one not be in the collision group so that the bunker buster will pass through the roof and first floor it encounters, but then explode on the bottom floor.

Or you can create an invisible collision mesh that fits inside the collision mesh of the bunker without interfering with other projectiles/soldiers/vehicles. Then you can design it to allow certain areas for the bunker buster to pass through but make it explode on others.

But most bunkers in BF1942 are mostly one floor in terms of layout, so you won't have to do anything too complicated. Though if there is a big space under the floor like a big gap between the terrain and the floor, then you may need to add a invisible collision mesh below the floor to give something for the bunker buster to explode on since otherwise it may go to deep below to damage any players inside the bunker. If you encounter issues with explosion splash damage not working properly for projectiles that explode below the floor, you can instead make only the roof and walls part of the collision group and make the floor a separate object. Or put a invisible collision mesh a few microns above the floor. It won't be high enough up to impact unrelated collisions like soldiers/vehicles/other projectiles, but it will be solid to the bunker buster and allow it to explode above the floor so that splash damage works correctly.

I've tested this in my BFH mod real quick and it works flawlessly. I added a tree to the unused collision group, then added a vehicle and one projectile to it. They both pass through the tree while everything else still collides with it. I may post a video at some point showing it off at a later time if needed. :D

Any other creative ideas for this? I'm sure a wide range of things can be done with this. :D
ImageImageImage
I have cameras in your head!
freddy
Posts: 1267
Joined: Sun Oct 18, 2009 4:58 pm

Re: Some interesting things achieved with c_CGStaticObjects

Post by freddy »

Very nice find Apache! I just went through the different collisiongroup settings in mdt a while ago and got nothing, i couldnt get c_CGLandscape to do anything for me either.
Also tried with adding c_CGLadders to some different objects to see if they would act as the ladders but got nothing.

Edit, havent seen c_CGStaticObjects before
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Some interesting things achieved with c_CGStaticObjects

Post by Apache Thunder »

Yeah I found c_CGStaticObjects while diving through the EXE with a hex editor. Found lots of things that way. There's stuff buried in there that even the command database and the MDT don't mention. :P
ImageImageImage
I have cameras in your head!
User avatar
Vilespring
Posts: 740
Joined: Sat Nov 24, 2012 5:47 am
Location: Somewere in the United States

Re: Some interesting things achieved with c_CGStaticObjects

Post by Vilespring »

My dreams have come true.
YEEEEESSSS!!!
I see many things with this unused collision group. Just one thing to clear up with me, giving 2 objects this line means they won't collide with each other, no matter their collision mesh?
A picture is worth a thousand words, but takes up three thousand times the memory.

Area 51: http://battlefieldarea51mod.weebly.com/

Image
"I didn't steal your pizza"
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Some interesting things achieved with c_CGStaticObjects

Post by Apache Thunder »

Yep. That's correct. Any two or more objects that are part of the same collision group will not interact with each other at all. If the object has child objects that have collision physics, they need to be part of the collision group to or they will prevent the object from passing through. (unless there's some creative use for not allowing child objects to pass through, But I can't think of any at the moment...EDIT: Wait perhaps train tracks and a train system of some kind? :P)

It won't matter what's going on with the collision meshes. The collision groups pretty much takes care of it for you.
ImageImageImage
I have cameras in your head!
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Some interesting things achieved with c_CGStaticObjects

Post by Apache Thunder »

Here's a video that shows how some of the weapons can shoot through certain objects:



The AK47/M16 and the M249/PKM can fire through fences and other small objects. (but not through buildings. Boat Wreck on Buccaneer Bay being the exception since the wood seems thin and bullets would pass through in the real world)

At the beginning of the video I show how they fire through the hay stacks on the island. Somewhere near the middle of the video, I show how I can fire through crates and kill the players in front. I switch to a pistol and show that the pistol is unable to shoot through that same crate. :D

Also shown are other stuff I packed onto the new Captain Shop island I built for my mod for kit spawns. :D
ImageImageImage
I have cameras in your head!
exe
Posts: 60
Joined: Wed Feb 08, 2012 10:04 pm

Re: Some interesting things achieved with c_CGStaticObjects

Post by exe »

There are definitely some interesting things possible with it, great find.

My idea was to add barbwire and all vehicles to this group, because they are very jumpy when you stop in it. But I think there's one problem: All vehicles would then be able to pass through each other, too. :(
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Some interesting things achieved with c_CGStaticObjects

Post by Diamondback »

Would it be possible to add the CTF flag objects to the collision group so that they do not fall through static objects when dropped? I’ll test it out.
See my Strasbourg map project here.
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Some interesting things achieved with c_CGStaticObjects

Post by Diamondback »

Tried it, didn’t work.
See my Strasbourg map project here.
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Some interesting things achieved with c_CGStaticObjects

Post by Apache Thunder »

The CTF flags are probably auto spawning on the terrain and don't have any kind of mobility or collision physics like the normal objects in the game. So no surprise that wouldn't work in this case.
ImageImageImage
I have cameras in your head!
Post Reply