Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Getting ZOOM Alt Attack to work just right

A topic by Scruffy86 created Apr 10, 2024 Views: 146
Viewing posts 1 to 1

I seem to be close to getting a working ZOOM function for a sniper rifle. Here is my FSM script for it, with the ZOOM Alt Attack: 

___________________________________________________________

BattleRifle.STATES

image BattleRifle 0 23

sound BattleRifleFire

sound BattleRifleReload


state IDLE NONE 0

frame 1 0.25 0 0 0 NONE

frame 1 0.25 0 0 0 ZOOM 0

frame 1 0.25 0 0 0 READY


state ATTACK IDLE 0

frame 2 .25 0 0 0 NONE

frame 3 .18 0 0 0 SOUNDANDATTACK 0

frame 4 .18 0 0 0 MUZZLEFLASH

frame 5 .15 0 0 0 NONE

frame 6 .15 0 0 0 NONE

frame 7 .18 0 0 0 NONE

frame 1 .2 0 0 0 NONE

frame 1 .1 0 0 0 NONE


state ALTATTACK IDLE 0

frame 23 0.01 0 0 0 NONE

frame 23 0.01 0 0 0 ZOOM 60

frame 23 0.01 0 0 0 READY


state RELOAD IDLE 0

frame 8 0.1 0 0 0 NONE

frame 9 0.1 0 0 0 SOUND 1

frame 10 0.1 0 0 0 NONE

frame 11 0.1 0 0 0 NONE

frame 12 .9 0 0 0 NONE

frameset 13 22 0.1 0 0 0 NONE

frame 1 .1 0 0 0 NONE

frame 1 .25 0 0 0 RELOAD

______________________________________________________________

Frame 23 is an invisible .png, I was hoping to be able to replace it with a scope image, a simple 1920x1080 black screen with a circle cut out and crosshair. But that didn't work. For now, I'm okay with just zooming in with no HUD graphics. 

The first problem is, when I hold the mouse right button, and fire with mouse left, when it fires, the weapon HUD sprite become visible again and shows the firing animation. I don't want it to show the weapon HUD. How do I do this?

Also, another issue, is when right mouse is held and the weapon is fired, afterwards, the zoom level resets instead of maintaining the zoom state. This creates an awkward loop of zooming, firing, zooming out, zooming in, firing, etc.