Jump to content

How to Disable the Weapon Fire/Shoot?


Recommended Posts


i've done this camera mode, but i want to add AIM function, which meant the player is disallowed to shot while running/walking, the player just can shoot when the player Aiming. the question is how to disable the fire while the player is running/walking? i'm thinking it would be similiar to OnStartSprinting function but i just found a row of code, please help.

i'm sorry before for my bad english



Link to comment
Share on other sites

  • 2 months later...
What about checking if the player is sprinting inside WeaponImage::onFire?

Why would you do that? It's already handled in the weapon state transitions - it Just Works™.

Let me clarify - handling it in the weapon state blocks is better because your onFire() method doesn't grow, stretch, and take longer and longer to execute every time you add another check. The only check is, what, "canFire?" and if it's not true you bail. Not, "if sprinting, else if sneezing, else if eating, else if snoring, else if crawling, else if lickingWindows...."

Link to comment
Share on other sites

  • 2 weeks later...

It's not a "can fire check" - it's a disabling of transition to the fire state.... "State machine."

Try it - just sprint and try to fire.

Look here - https://github.com/GarageGames/Torque3D/blob/development/Templates/Full/game/art/datablocks/weapons/Lurker.cs#L784

This state block and the next two cover the sprint enter, sprinting, and sprint exit state transitions - note that you cannot transition to the fire state from these states. So no check ever needs to be made anywhere else - you simply can't transition into a firing state because it's not valid.

And I don't see any check for canFire in https://github.com/GarageGames/Torque3D/blob/development/Templates/Full/game/scripts/server/weapon.cs#L179 at all.

Having said that - do it however you like. Your game, your way. But you did ask, so I thought I'd explain how it was already done.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...