[4.1.5] Switch Players Action State From Jumping Once Player Touches Ground

Vonwoah

New member
Version 4.1.5
Starting Module: BASE_ScrollingPlatformer.MOD

EDIT: Turns out the previous script was unnecessary. If you are running 4.1.5 and use the Scrolling Platform module, the fix can be applied to ModuleScripts/MainScripts/ScrollingPlatformer/ExtraControllReadCode.asm

Code:
ExtraInputControl:
    
	;; Change player to standing/idle state once touching ground
	LDX player1_object
	LDA Object_physics_byte,x
	AND #%00000001 ;; is on ground
	BEQ +
	GetCurrentActionType player1_object
	CMP #$03 ;; jumping state
	BNE +
	ChangeObjectState #$00, #$04 ;; idle state
	+
	
	RTS
 

Mugi

Member
you can simply check against the object physics byte to see if the player is in the air or not by doing

LDA Object_physics_byte,x
AND #%00000001 ; if is in air

and change the actionstate back to idle from the jump script itself if the condition is not met.
i think nesmaker's engine does this by default in the extra controller script that runs after every input, but if my memory serves me right it had some issues with the default configuration it came with.
a lot of people experienced broken input actions/animation states when the version containing this script was added to the engine and there's some old threads in the forum archive about dealing with it.
 

Vonwoah

New member
Mugi said:
a lot of people experienced broken input actions/animation states when the version containing this script was added to the engine and there's some old threads in the forum archive about dealing with it

I've seen a number of threads involving broken animation states, and I haven't seen any fixes for jumping in 4_1_5. Do you know where I might find this? I've tried every jump script out there, and even wrote my own from scratch and still can't get the jump action state to end when the player touches the ground. This is because my command to test for ground overrides my jump animation. If it's in the jump script, this all executes once with a press of a button. It don't know how to conditionally check for the jump animation to stop after pressing A jump + player jumps + idle animation when touching ground. This logic is in my test script, but it's overriding my jump values because I can only test for air or ground with a press of a button. I'm trying to figure out how to end it without a timer and landing on the ground.

This is the current state of the 4_1_5 scrollingPlatformer. Below is my rewritten jump script that is still broken. I've tested with a blank project and do see that the ending of jump actions do not end. I've been trying to fix this for weeks, so any help is appreciated.

Code:
;; THIS CODE IS FOR JUMPING.
LDX player1_object

;; Our jump
LDA Object_physics_byte,x
AND #$00000100
BEQ +
	ChangeObjectState #$02, #$04
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;; set the vertical speed to a negative number to make it "jump".	
	LDA #$00
	SEC
    SBC #JUMP_SPEED_LO
    STA Object_v_speed_lo,x
    LDA #$00
    SEC
    SBC #JUMP_SPEED_HI
    STA Object_v_speed_hi,x	
	BEQ noJump
+
	
;; this just overrides above on button press because the player starts out on the ground
;; hmmmmmm
	LDA Object_physics_byte,x
	AND #$00000001 ;;
	BEQ noJump
	ChangeObjectState #$00, #$04
	+
	
noJump:
	;; no way to determine after object jump, to change to state #$00 when touching ground
	;; since everything is determined by a single press of a button
	RTS
 

dale_coop

Moderator
Staff member
The issue comes not from your jump script... but from the Handle Extra Controls script...(my guess) ;)
 

Vonwoah

New member
Thank you Mugi and Dale.

Turns out it was the Handle Extra Control script! Previously I was looking here and I zeroed it out to just return RTS. This is exactly what I needed, control to modify the action after input. I applied this code to ExtraControllReadCode.asm. From my previous tests, I remember the 4.1.5 scrollingPlatform module doesn't take care of changing the players state to idle when touching the ground. If anyone else has this problem.

Code:
ExtraInputControl:
    
	;; Change player to standing/idle state once touching ground
	LDX player1_object
	LDA Object_physics_byte,x
	AND #%00000001 ;; is on ground
	BEQ +
	GetCurrentActionType player1_object
	CMP #$03 ;; jumping state
	BNE +
	ChangeObjectState #$00, #$04 ;; idle state
	+
	
	RTS

Thank you! Thank you! Thank you!
 

modeschar

New member
This doesn't seem to work for me when I add it to ExtraControllReadCode.asm. The player still has the jumping animation until I let go of the directional pad.
 
Top Bottom