Search Unity

Weapon Change

Discussion in 'FPS.Sample Game' started by IanHonorato, Jun 4, 2019.

  1. IanHonorato

    IanHonorato

    Joined:
    Apr 9, 2019
    Posts:
    6
    I'm trying without sucess to change the weapon without changing the character(as it's working in "nextchar" command).
     
  2. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    50
    Do you want to change it in-game, while playing or before the game loads?
     
  3. IanHonorato

    IanHonorato

    Joined:
    Apr 9, 2019
    Posts:
    6
    While playing
     
  4. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    50
    Okay, I haven't done that part yet :)

    But you have a scriptable obejct (.asset file) somewhere that holds the current weapon for each hero.
    So you could expand that to hold more weapons and then switch between them while running the game.
    Set 1 weapon as the default and set the others to inactive.
    Then press a key and change which weapon is active.
     
  5. nanodiniz

    nanodiniz

    Joined:
    Feb 19, 2019
    Posts:
    3
    Do you know in wich script the weapon is set as active? I tried expanding to hold more weapons but the fps sample called all the weapons at the same time(though it kept the way of firing of the first weapon).
     
  6. minibotan

    minibotan

    Joined:
    Oct 4, 2016
    Posts:
    15
    in my game i made that you can pickup any weapon that appears on the floor and it replaces current one.
    so i despawn all abilities that been on this weapon and then despawn it.
    after that i create a new weapon, create abiliteas and attach them to the player
     
  7. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    50
    I think you would have to make that script yourself.
    ...or add it to an existing one.
     
  8. nanoblubb

    nanoblubb

    Joined:
    Oct 29, 2016
    Posts:
    9
    Yeah probably you should make a script, that is able to fire a diffrent range of weapons (not such specific like chain gun / autorifle) More like something where you can define type of weapon (shotgun / rifle /melee), type of bullet (cast or dynamic) etc. The problem for me is understanding how the weapons work in the fps game kit. Its a bit confusing that they are seem to be "Abilitys" for the functionality and items for the local animation / vfx effects. So Do i´need to make smt like the Chaingun_Ability to do the actual networked shooting? Did i understood you right, that you would just swap out than the values for the current weapon (wich is currently hardcoded in the weapon definition)? Any idea how to register than the new weapon mesh and animations (because now its just added at start up with the current character as far I can see)