Idle animation not activating 4.1

digitalbooty

New member
Anyone else having issues getting the player to activate it's idle animation while just standing without any input? I'm using the scrolling platform in case that makes a difference.
 

Mugi

Member
I noticed this too and due to the changed mechanics of how 4.1.0 handles things it took me quite a while to fix all the animation problems.
here's my assemblies for that, that make idle animation trigger correctly, and fixes jump to trigger when you walk off a ledge.

these are not complete though, i still havent worked on hurt, crouch or attack, so they might still not work properly with those.


assign this to "hold left"
Code:
    LDX player1_object
    LDA Object_physics_byte,x
    AND #%00000001              ; Are we in the air ?
    BEQ SwitchToJump_Left
    GetCurrentActionType player1_object
    CMP #$01                    ; Are we already walking ?
    BEQ skipStateChange_Left
    CMP #$03                    ; Are we attacking ?
    BEQ skipStateChange_Left
    ChangeObjectState #$01, #$03
skipStateChange_Left:
    StartMoving player1_object, MOVE_LEFT
    FaceDirection player1_object, FACE_LEFT
    RTS
SwitchToJump_Left:
    GetCurrentActionType player1_object
    CMP #$02                    ; Are we already in jump animation ?
    BEQ skipStateChange_Left
    ChangeObjectState #$02, #$03
    JMP skipStateChange_Left

assign this to "hold right"
Code:
    LDX player1_object
    LDA Object_physics_byte,x
    AND #%00000001              ; Are we in the air ?
    BEQ SwitchToJump_Right
    GetCurrentActionType player1_object
    CMP #$01                    ; Are we already walking ?
    BEQ skipStateChange_Right
    CMP #$03                    ; Are we attacking ?
    BEQ skipStateChange_Right
    ChangeObjectState #$01, #$03
skipStateChange_Right:
    StartMoving player1_object, MOVE_RIGHT
    FaceDirection player1_object, FACE_RIGHT
    RTS
SwitchToJump_Right:
    GetCurrentActionType player1_object
    CMP #$02                    ; Are we already in jump animation ?
    BEQ skipStateChange_Right
    ChangeObjectState #$02, #$03
    JMP skipStateChange_Right

go to project settings, script settings, and open Extra Controll Script:
at line 61, change this:
Code:
notInAir:
    LDA Object_h_speed_lo,x
    ORA Object_h_speed_hi,x

to this:
Code:
notInAir:
				; add an extra "set to idle state" here for fixing jump state animation glitching.
	ChangeObjectState #$00, #$03
	LDA Object_h_speed_lo,x
	ORA Object_h_speed_hi,x

these fix the jump animation being "stuck" if you dont input anything, and they correctly change you into jumping animation when you walk off a ledge and start falling.
 
Mugi said:
go to project settings, script settings, and open Extra Controll Script:
at line 61, change this:
Code:
notInAir:
    LDA Object_h_speed_lo,x
    ORA Object_h_speed_hi,x

to this:
Code:
notInAir:
				; add an extra "set to idle state" here for fixing jump state animation glitching.
	ChangeObjectState #$00, #$03
	LDA Object_h_speed_lo,x
	ORA Object_h_speed_hi,x

Is there a line missing in this fix? Adding the ChangeObjectState #$00, #$03 line causes a scripting error of branch out of range.
 

Mugi

Member
ah yeah, it's because i removed the below code for the hardcoded "crouch" code. If you leave that in, you get a branch out of range with it.

if you dont need that, here's my full file;
Code:
ExtraInputControl:

    ;;; occasionally, there is input code that may be very specific, and it may be 
    ;;; difficult to implement via the visual interface and accompanying scripts.
    ;;; this is a code that runs after all input checks, and allows for custom ASM.
	LDA gameState
	CMP #GS_MainGame
	BEQ doMainGameUpdates
	JMP skipMainGameExtraInputControl
doMainGameUpdates:  
	LDX player1_object
	GetCurrentActionType player1_object
	STA temp
	LDA Object_physics_byte,x
	AND #%00000010
	BEQ isNotClimbing
	LDA temp
	CMP #$04
	BNE isNotClimbing
	LDA gamepad
	AND #%11000000
	BEQ noDirWhileClimbing
;ChangeObjectState #$02, #$04
noDirWhileClimbing:
				; is climbing.
				; which means don't check to change to idle.
	JMP skipMainGameExtraInputControl
isNotClimbing:
	LDA temp
	CMP #$03 ;; is it shooting (shooting is same anim in air and on ground)
	BNE isNotAttackingAction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	JMP skipMainGameExtraInputControl
isNotAttackingAction:   
	LDA gamepad
	AND #%11000000		; left and right
	BEQ dontskipMainGameExtraInputControl
	JMP skipMainGameExtraInputControl
dontskipMainGameExtraInputControl:
				; if left and right are not pressed
	
	LDA screenFlags
	AND #%00100000 		; does it use gravity?
				; if it does not, it would not have jumping or ducking, so
				; skip state updates for jumping and ducking.
	BEQ notDucking		; just will change to idle.
	LDA Object_physics_byte,x
	AND #%00000001		; if is in air
	BNE notInAir
	GetCurrentActionType player1_object
	CMP #$02		; is it already state 2?
	BEQ skipMainGameExtraInputControl
	ChangeObjectState #$02, #$04
	JMP skipMainGameExtraInputControl
notInAir:
				; add an extra "set to idle state" here for fixing jump state animation glitching.
	ChangeObjectState #$00, #$03
	LDA Object_h_speed_lo,x
	ORA Object_h_speed_hi,x
	BNE skipMainGameExtraInputControl
		; controller is not pressed
		; horizontal speed is zero.
		; check to see if in air, shooting, etc.

; TO-DO: figure out what this is used for ??
;	LDA gamepad
;	AND #%00100000 ; if down is pressed
;	BEQ notDucking
;	ChangeObjectState #$05, #$04
;	JMP skipMainGameExtraInputControl
notDucking:
	LDA gamepad
	AND #%11110000
	BNE skipMainGameExtraInputControl
	ChangeObjectState #$00, #$04
skipMainGameExtraInputControl:  
    
    RTS

but if you do need that crouch code, then what you have to do is set up a JSR for the notducking because it's too far in the code. Thanks for letting me know, i'll have to poke at that.
I haven't really written these clean yet, since like i said, i still have a bunch of mechanics to work through before my player handles like i want.
Im working on making a crouch that does not spend a object state, and is done with animations instead, and might try and pull that off with crouch attack too, but we'll see. I will have to test how much the engine agrees with my plans.
 

Mugi

Member
well, i took a poke at it, and might not be perfect but here's a functional version with "ducking" included.

Code:
ExtraInputControl:

    ;;; occasionally, there is input code that may be very specific, and it may be 
    ;;; difficult to implement via the visual interface and accompanying scripts.
    ;;; this is a code that runs after all input checks, and allows for custom ASM.
	LDA gameState
	CMP #GS_MainGame
	BEQ doMainGameUpdates
	JMP skipMainGameExtraInputControl
doMainGameUpdates:  
	LDX player1_object
	GetCurrentActionType player1_object
	STA temp
	LDA Object_physics_byte,x
	AND #%00000010
	BEQ isNotClimbing
	LDA temp
	CMP #$04
	BNE isNotClimbing
	LDA gamepad
	AND #%11000000
	BEQ noDirWhileClimbing
;ChangeObjectState #$02, #$04
noDirWhileClimbing:
				; is climbing.
				; which means don't check to change to idle.
	JMP skipMainGameExtraInputControl
isNotClimbing:
	LDA temp
	CMP #$03 ;; is it shooting (shooting is same anim in air and on ground)
	BNE isNotAttackingAction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	JMP skipMainGameExtraInputControl
isNotAttackingAction:   
	LDA gamepad
	AND #%11000000		; left and right
	BEQ dontskipMainGameExtraInputControl
	JMP skipMainGameExtraInputControl
dontskipMainGameExtraInputControl:
				; if left and right are not pressed
	
	LDA screenFlags
	AND #%00100000 		; does it use gravity?
				; if it does not, it would not have jumping or ducking, so
				; skip state updates for jumping and ducking.
	BNE proceedFurther	; just will change to idle.
	JMP notDucking
proceedFurther:
	LDA Object_physics_byte,x
	AND #%00000001		; if is in air
	BNE notInAir
	GetCurrentActionType player1_object
	CMP #$02		; is it already state 2?
	BNE proceedFurther2
	RTS
proceedFurther2:
	ChangeObjectState #$02, #$04
	JMP skipMainGameExtraInputControl
notInAir:
				; add an extra "set to idle state" here for fixing jump state animation glitching.
	GetCurrentActionType player1_object
	CMP #$05
	BEQ skipMainGameExtraInputControl
	ChangeObjectState #$00, #$03
	LDA Object_h_speed_lo,x
	ORA Object_h_speed_hi,x
	BNE skipMainGameExtraInputControl
		; controller is not pressed
		; horizontal speed is zero.
		; check to see if in air, shooting, etc.

; TO-DO: figure out what this is used for ??
	LDA gamepad
	AND #%00100000 ; if down is pressed
	BEQ notDucking
	ChangeObjectState #$05, #$04
	JMP skipMainGameExtraInputControl

notDucking:
	LDA gamepad
	AND #%11110000
	BNE skipMainGameExtraInputControl
	ChangeObjectState #$00, #$04

skipMainGameExtraInputControl:  
    
    RTS

i also added another extra line to this file at line 62 (start of "notinair:" that checks for action state 05 (i use 05 for hurt)) and ignored inputs if in hurt state, i call it "let me hurt in peace" which i believe platformers should have, that prevents you from moving during your hurt state. If you dont want it, remove the part:

Code:
	GetCurrentActionType player1_object
	CMP #$05
	BEQ skipMainGameExtraInputControl

the original code uses state 05 for ducking so it propably doesnt work that well if you use it for that.
 

dale_coop

Moderator
Staff member
Thanks for sharing Mugi, your modifications are interesting...

For fix the idle animation, I did replace (at the end of the original ExtraControlReadCode.asm file) that lines:
Code:
notDucking:
	LDA gamepad
	AND #%11110000
	BNE skipMainGameExtraInputControl
	ChangeObjectState #$00, #$04
skipMainGameExtraInputControl:  
    
    RTS

with that:
Code:
skipMainGameExtraInputControl:
	RTS

notDucking:
	LDA gamepad
	AND #%11110000
	BNE skipMainGameExtraInputControl2
	GetCurrentActionType player1_object  ; check curren state
	BEQ skipMainGameExtraInputControl2   ; if already 0, don't change it again.
	ChangeObjectState #$00, #$04
skipMainGameExtraInputControl2:
	RTS
 

Mugi

Member
well i've been doing 200 things with this for the moment, i still need to poke at the whole ignore inputs during recoil, and im working on the recoil physics at the moment.
the backwards sliding recoil is not really suitable for my game, so im making one that bounces up a little. It works so far but it's a little buggy, could eb because of all the extra scrolling stuff going on.

as for my fix, the primary function of it was not to fix the stuck on the airjump, it was to fix the "not air animation when walking off a ledge" .......but side effects :p
i just posted it since it does work, but Im quite aware that it looks terrible. Once i have it doing everything i want it to do, i will write it clean along with the input assemblies that are also a mess.
 

Mugi

Member
dale's is propably a better solution.
at the point where i posted my scripts here, they were going through some quite rough poking.

what matters is that either works, so people can get over that problem :)
 

jermz

New member
Is anyone having this problem with the Adventure module? My animations aren't changing when I move and stop (walking to idle) even though I'm certain it's all set up correctly in the player object properties, even followed the steps in the Input Management tutorial.
 

jermz

New member
In case anyone is having the same issue as I was with the Adventure module, this is what I did. Assuming Action 0 is idle and Action 1 is walking for the player object animations, I added these lines to the StartMovingPlayer* scripts right after the first instance of the + label (single line with only a + on it):

Code:
    GetCurrentActionType player1_object
    CMP #$01
    BEQ ++++++
    ChangeObjectState #$01, #$04
++++++

and this to the StopMovingPlayer* scripts, also after the first instance of the + label:

Code:
    GetCurrentActionType player1_object
    CMP #$00
    BEQ ++++++
    ChangeObjectState #$00, #$04
++++++

This should, if I've done it correctly, start the correct animations for idle and walking if they are not already running, in any game the doesn't have the gravity flag set (eg. games where you don't jump or fall). I tested it and it seems to work :) but then again, I've just started this project so hopefully it doesn't break anything.
 

jermz

New member
So I realized I made a mistake/missed something. There are definitely scripts for changing to idle/walk animations already, they just weren't showing up before when I was adding input scripts. I've had some trouble with open/save dialogs on my system loading really slow and file lists loading really slow so I'm just going to guess that's why I couldn't see all the scripts before. The code I posted before should be unnecessary and if someone for some reason wanted to hard-code that behavior into the movement scripts, they should just refer to the changeToIdleAnimation and changeToWalkingAnimation asm scripts.
 

dale_coop

Moderator
Staff member
jermz, the "changeToIdleAnimation" and "changeToWalkingAnimation" are old scripts from previous version, they don't exists anymore in the 4.1 (and are obsolete). This leads me to this question: what version are you using? The 4.0 maybe?
Every versions of NESMaker have their own particularities, specificities, issues, ... an answer that work for the 4.1 would not work the the 4.0 and vice-versa.

So yep, if you are in 4.0 and having issues with animations... your answers are in the adventure module tutorial video for the 4.0 (on youtube) and your input editor links issues could find answers maybe here: http://nesmakers.com/viewtopic.php?t=533
 

jermz

New member
dale_coop said:
jermz, the "changeToIdleAnimation" and "changeToWalkingAnimation" are old scripts from previous version, they don't exists anymore in the 4.1 (and are obsolete). This leads me to this question: what version are you using? The 4.0 maybe?
Every versions of NESMaker have their own particularities, specificities, issues, ... an answer that work for the 4.1 would not work the the 4.0 and vice-versa.

So yep, if you are in 4.0 and having issues with animations... your answers are in the adventure module tutorial video for the 4.0 (on youtube) and your input editor links issues could find answers maybe here: http://nesmakers.com/viewtopic.php?t=533

In v.4.1.0 0x158, those "change animation" scripts are in GameEngineData>Routines>Basic>ModuleScripts>MovementScripts subdirectory, whereas before they were in a module specific subdirectory AFAIK. They seem to still function as in previous versions. It's possible that a newer build of NesMaker 4.1 came out after I installed mine, though.
 

dale_coop

Moderator
Staff member
It's not they don't work... it's just we don't need to use them anymore in the 4.1 because everything is done with the StartMovingPlayerXXX.asm and StopMovingPlayerXXX.asm (movements, facing and animations).
 

Lother

Member
So how the complete code should look like ? Because when I compile, I end up with that:
Routines\Basic\ModuleScripts\MainScripts\ScrollingPlatformer\ExtraControllReadCode.asm(50): Branch out of range.

For information I've added the bit of code for fixing the jump animation by Mugi and the idle animation fix by Dale-coop and nothing else.

Here's my code:

Code:
ExtraInputControl:

    ;;; occasionally, there is input code that may be very specific, and it may be 
    ;;; difficult to implement via the visual interface and accompanying scripts.
    ;;; this is a code that runs after all input checks, and allows for custom ASM.
    LDA gameState
    CMP #GS_MainGame
    BEQ doMainGameUpdates
    JMP skipMainGameExtraInputControl
doMainGameUpdates:  
    LDX player1_object

	GetCurrentActionType player1_object
	STA temp
	LDA Object_physics_byte,x
	AND #%00000010
	BEQ isNotClimbing
    LDA temp
    CMP #$04
    BNE isNotClimbing
	LDA gamepad
	AND #%11000000
	BEQ noDirWhileClimbing
	ChangeObjectState #$02, #$04
noDirWhileClimbing:
    ;;; is climbing.
    ;;; which means don't check to change to idle.
   JMP skipMainGameExtraInputControl
isNotClimbing:
    LDA temp
    CMP #$03 ;; is it shooting (shooting is same anim in air and on ground)
    BNE isNotAttackingAction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    JMP skipMainGameExtraInputControl
isNotAttackingAction:   

    
    LDA gamepad
    AND #%11000000 ;;; left and right
    BEQ dontskipMainGameExtraInputControl
	JMP skipMainGameExtraInputControl
dontskipMainGameExtraInputControl:
    ;;; if left and right are not pressed
	
	LDA screenFlags
	AND #%00100000 ;; does it use gravity?
					;; if it does not, it would not have jumping or ducking, so
					;; skip state updates for jumping and ducking.
	BEQ notDucking ;; just will change to idle.

    LDA Object_physics_byte,x
    AND #%00000001 ;; if is in air
    BNE notInAir
    GetCurrentActionType player1_object
    CMP #$02 ;; is it already state 2?
    BEQ skipMainGameExtraInputControl

    ChangeObjectState #$02, #$04
    JMP skipMainGameExtraInputControl
notInAir:
				; add an extra "set to idle state" here for fixing jump state animation glitching.
	ChangeObjectState #$00, #$03
	LDA Object_h_speed_lo,x
	ORA Object_h_speed_hi,x
    BNE skipMainGameExtraInputControl
    ;;;; controller is not pressed
    ;;;; horizontal speed is zero.
    ;; check to see if in air, shooting, etc.
	 LDA gamepad
	AND #%00100000 ; if down is pressed
	BEQ notDucking
	 ChangeObjectState #$5, #$04
	 JMP skipMainGameExtraInputControl
skipMainGameExtraInputControl:
	RTS

notDucking:
	LDA gamepad
	AND #%11110000
	BNE skipMainGameExtraInputControl2
	GetCurrentActionType player1_object  ; check curren state
	BEQ skipMainGameExtraInputControl2   ; if already 0, don't change it again.
	ChangeObjectState #$00, #$04
skipMainGameExtraInputControl2:
	RTS
 

dale_coop

Moderator
Staff member
Because the notDucking is too far for the the branch out..
You could try reversing the tests... replacing every:
Code:
	BEQ notDucking
By:
Code:
	BNE +
	JMP notDucking
	+
 
Top Bottom