Page 1 of 1
Collision Confusion
Posted: Sat Mar 03, 2012 6:28 am
by steverz
So, long story short, I have been messing with battlefield, and I want to make a projectile that imparts force. It started off with a grenade that had such a large mass that it sent takes flying with the slightest hit. I also wanted to make it where the grenade would hit the player. Not to kill the player, but say you threw a grenade and it hit someone it would bounce off of them instead of going through them as the game currently does. I tried changing materials and turning point physics on and off (I would love to hear what point physics actually is) and after lots of tweaking the best I can seem to do is make a projectile that still passes right through the players but hits everything else. I'm not sure what I'm missing. I read through the tutorials on the damage system, and I've played with various materials and yet I still can't achieve my goal.
The projectile I'm trying to achieve behaves much like a jeep body in that it has mass and collides with everything while imparting force and damage to the target.
Here is my most current test projectile. It works well on any kind of moveable object that is occupied. It doesn't seem to work on unoccupied vehicles though. Any help would be more than awesome!
Code: Select all
ObjectTemplate.create Projectile M1GarandProjectile
ObjectTemplate.geometry bullet_m1
ObjectTemplate.timeToLive CRD_NONE/1/0/0
ObjectTemplate.gravityModifier 0
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.hasPointPhysics 0
ObjectTemplate.invisible 1
ObjectTemplate.material 45
ObjectTemplate.mass 9999999
ObjectTemplate.loadSoundScript ..\..\common\Sounds\projectile.ssc
Re: Collision Confusion
Posted: Sat Mar 03, 2012 7:59 am
by Apache Thunder
Projectiles will never have any interaction with soldiers. It's hard coded. I recall a very old version of BF1942 where the TNT and possibly other projectiles can stick to or bounce of soldiers, but it was disabled in a game patch at some point.
As for making the grenade hitting a vehicle and making it move....the only way I can think of doing that without killing the projectile is by turning on sticky attribute:
Increasing the mass and/or the velocity of the grenade will amplify the movement of the vehicle the projectile will impart onto the vehicle. it's one of the bugs associated with this code. When a sticky projectile hits a vehicle it will impart reverse inertia onto the host vehicle. (so the vehicle will move towards the projectile and not away from it when the projectile sticks to it) Larger mass or faster projectile movement amplifies it. Try making gun bullets sticky and firing it a vehicle. It will send it flying so fast that it will practically vanish before your eyes.
But if you end up using that code, be sure you remove any network info from the grenade projectile you would use it on. There's a CTD bug that occurs if the player uses a networked sticky projectile and puts it on a vehicle and the player or vehicle it is stuck to dies and disappears from the map while the projectile is still active. Networked projectiles will disappear when the host player's kit that had the weapon that fired that projectile disappears. If a soldier dies on foot, the kit will remain on the map for 20 seconds and the projectile will remain for 20 seconds. If the player dies in a vehicle, the kit and projectile are removed immediately. So if the projectile's both networking and isSticky code enabled and one of those conditions occur, the game will CTD. The code will work fine on all non networked projectiles.
Re: Collision Confusion
Posted: Sat Mar 03, 2012 8:59 am
by steverz
Thank you for your reply! I made the grenades work in that they sirvive the bounces, but only because they were a timed projectile I think. I've noticed how the physics tends to work backwards, so I throw a grenade at an enemy tank and then the tank flys forward and crushes my team lolololol. Anyhow, I didn't realize that the game simply didn't factor in projectile colisions with soldiers. Since it doesn't the question becomes: Can I make the weapon spawn an opject and then propell that object forward? I can just imagine the complexity of this, but I wonder if its possible. If so, I could have the gun spawn say a jeep body and then propell it forward and destroy troops and vehicles.
Re: Collision Confusion
Posted: Sat Mar 03, 2012 4:25 pm
by Apache Thunder
You can spawn vehicles via a weapon by making an invisible projectile that has a spawner addtemplated to it. Make sure the invisible projectile has a very short timeToLive. 0.3 or so should be short enough.
Then it will spawn where the projectile is. You may need to add "ObjectTemplate.forwardMod" to the vehicle you have it spawn if you want it to move foward towards your target when it spawns. It is a float value, so the code should appear as "ObjectTemplate.forwardMod 50" for example. HIgher numbers = higher speeds.
Look at my AP Mines in my DCU mod or the Troop Traps in my BFHeroes mod, they spawn as PCOs when fired from the handweapon and use the spawner system similar to what you need.
Posted: Sat Mar 03, 2012 8:57 pm
by freddy
Code: Select all
ObjectTemplate.Active KnifeProjectile
ObjectTemplate.addTemplate ArtillerySpawner
ObjectTemplate.setPosition 0/0/2
ObjectTemplate.create ObjectSpawner ArtillerySpawner
ObjectTemplate.setObjectTemplate 1 KettenKrad
ObjectTemplate.team 1
ObjectTemplate.holdObject 1
http://youtu.be/dDyPfB3076o?t=10s
Re: Collision Confusion
Posted: Sun Mar 04, 2012 10:05 pm
by Dennis|8749236
That is not artillery = P
Re: Collision Confusion
Posted: Mon Mar 05, 2012 12:51 am
by Swaffy
Not unless you stick naval guns on that little thing.
But ApacheThunder, I thought the isSticky code only works in BF Vietnam?
It actually works in BF'42 (without networked projectiles)?
Re: Collision Confusion
Posted: Wed Mar 07, 2012 2:51 pm
by Dennis|8749236
Worked but buggy >.<