How can a vehicle passenger fire his own gun?
I want to make my vehicle passenger pawn fire his own gun and be able to switch ground player pawn weapons while in the seat. How can I do this? :bulb:
Well since it's going to be a passenger of some vehicle, you'll probably start off making a class that derives from ONSWeaponPawn. You'll then have to use this class to decide what weapon the player currently has selected and do the firing stuff.
You may want to look through the classes xPawn, PlayerController and Weapon to both figure out exactly how Inventory Weapons Fire and Vehicle Weapons Fire. Then you'll have to decide based on that what changes you need to implement to make the vehicle firing code use regular weapons.
I do seem to remember the ASVehicle->ASTurret class uses an inventory->weapon object for it's firing so that may be another place to look through.
You'll add your ONSWeaponPawn derived class to your vehicle with
PassengerWeapons(n)=(WeaponPawnClass=MyPackage.MyC lass,WeaponBone="BoneToMountTheClassToOnTheVehicle ")
Hope this is of some help to you.
Thanks for the reply.
I have a class already that extends ONSWeaponPawn but currently the player has no projectile to shoot. And he of course is attached to a bone. I do have a passengerweapon(0) in my vehicle class already so that's no problem.
I was just wondering what to put in my Pawn class in order for him to make him fire his own gun.
wouldnt the pieces just bounce off the inside of the vehicle?
You need to redefine the function that attaches players/bots to vehicles. What you need to change is instead of making the player one with the vehicle, you need to do an "AttachToBone" on the player. This essentially glues the player onto the vehicle without adding the player to the crew. Just don't overlap crew and passenger entry points.
If I were at my code base, I could get more specific. If you have UDE you should do a search for "DriverWeapons" in ONSVehicle.uc. At least on occurence will end up in the function you need to overload. Don't change ONSVehicle, change the function in your inherited class.