Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How do I fix my weapon swapping

I'm watching the video about weapon switching and I only have two weapons, the problems are that 1, It doesn't stop me from picking past numbers 0 and 1 (weapons) 2, both my weapons seem to be inside each other when the game loads stopping the switching to work properly.

Answers

  • edited June 2020

    i don't understand totally but i'm using this basic algorithm for switching weapons, maybe it helps:

    void switchWeapon(){

    weapon[onHand].gameObject.SetActive(false);

    if(onHand=!weapon.Lenght-1){

    onHand++;

    }

    else{

    onHand=0;

    }

    weapon[onHand].gameObject.SetActive(true);

    }

    weapon is a gameobject array.

  • MrSlugMrSlug Member

    Hi @EletricDragonYT ,

    Can you post your code so we can see what's causing the problem? It sounds like the active weapon isn't being cleared when you swap weapons.

    Cheers,

    Slug

  • hey im not working on that anymore so could this thread be deleted?

  • WarpWarp Administrator

    No, generally threads should not be deleted.

    Anyone with the same issue can open this thread and see @yoda_from_star_trek answer, and get information from that, so its really important that things like this stay up.

Sign In or Register to comment.