Search Unity

Add new projectile?

Discussion in 'FPS.Sample Game' started by devinpquinn, Mar 14, 2019.

  1. devinpquinn

    devinpquinn

    Joined:
    Aug 30, 2018
    Posts:
    8
    First forum post (woo!),

    I'm looking to create a new type of projectile and replace one or both of the fire modes with it. I've been poking around in the scripts but I'm much too scared to touch anything without seeking advice from wise folks such as yourself. My question is, where should I start? Anything along the lines of "oh, just create a new asset of this type or a new prefab like this and then edit this script bada bing bada boom" or even "probably look at this file' would be super helpful. Thanks in advance! I look forward to being confused about your answer.
     
  2. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    81
    There are 2 types of projectile in the game. A hitscan based (ray cast) and a physics based. The terraformer girl uses the hitscan and the robot uses the physics one.

    Each type is thrown into the game in an object pool and you can adjust the amount in the scriptable objests .assets files.

    To make a new projectile you should first create an asset for it by right-clicking and select create/fpsSample/projectile/projectileTypeDefinition. This asset file them contains data like damage and speed etc...

    Then you need to register these new asset files by clicking "register"...
    There is also some regs files that you might need to look through in a folder called "bundledResourses/shared"...

    these registries can be a bit tricky so there is a few tools to help you see whats going on.
    Go to FpsSample menu and then registries and testRegistries.
    This will give you a list of how the different regs are doing.
    This is all based on memory so there might be some inaccuraties :)

    In our project we simple took their projectiles and changed their stats to what we needed.
    For now we ended up only using the hitscan type.

    One last thing to know is that the projectiles are made up of different elements that are not linked to each other.
    Meaning that the raycast fires to see if you hit something has nothing to do with the visual bullet you see flying thought the game in 3rd person or from the other clients. And this visual bullet has its own asset files for speed etc...

    And then again, the bullet impacts are linked to the hitscans and you can therefor see you bullet hit walls before the visuals arrive at the same wall.

    Hopefully this gives you a direction to start with?
    :)
     
  3. devinpquinn

    devinpquinn

    Joined:
    Aug 30, 2018
    Posts:
    8
    Thank you so much with the response! This is definitely exactly the direction I was looking for.