Top Down shooter

Hi all. I am at the end of my tether here my game hinges upon this mechanic. I have tried looking at tuts, asking on the discord server, but every solution, either through ineptness and lack of knowledge has resulted in dismal failure. So I am asking outright for a bit more detailed help. Assume I know nothing.

The game as it stands so far:

  • Has a Player with multiple (at least two weapon sets) complete with topdown movement anims and melee and pistol
  • Has a test arena already set up with barriers and collisions
  • Has a main menu (NO ISSUES THERE)

How it plays now:

  • Player can move diagonally and follow a cross hair in the direction its pointing at.
  • Player can punch and kick (left and right click)
  • Holding shift and forward and backwards, makes him run and anims respond accordingly.
  • Pressing 1 and 2 keys switches character animation sets between fists and pistol with each its own anim sets

The Problem:

  • when pressing 1 or 2 keys they switch weapons, but pressing the same button again (cuz it will happen by accident) spawns another copy in a random location. I need it to just switch weapons and even when pressing the same key again, wont spawn another copy of the character.

What I think I did wrong:

  • I created the player as an object with a trigger once with a set size and it deletes the last player when switching weapons. Some one said I need to use variables and set anim states but I have failed to do so.
    All I want is to switch weapons with no extra player spawning so I can add more weapon sets and anims.

What am I doing wrong?

Sharing a screenshot of the related events (keypresses) helps us help you, but all you need is to add a condition to avoid duplicates.
If pressing 1 creates Player1, add a condition to that keypress to check the number of Player1 objects on the scene, or use a variable (e.g. If variable WhichAnimationOfPlayer is NOT 1 and key 1 is pressed, create Player1).

Yeah sorry I am at work, will share in a bit

Thanks I will try that

As you see it spawns another char when the same button is pressed again

It’s acting in accordance with your events.
Unless you have a good reason for using two different player objects, I would recommend you to use change animation instead of delete/create.
Aside from that, you can use the fix I explained above.

would change animation still use all the animations under that set?

The animation would play all of its frames, yes.

Thanks bro, appreciate the help!

1 Like