Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Newby | |
Old Version | Published before Godot 3 was released. |
I dont know why its happening im looking at my code and i cant find anything wrong with it.
func _fixed_process(delta):
PLAYERSTATE_PREV=PLAYERSTATE
PLAYERSTATE=PLAYERSTATE_NEXT
ORIENTATION_PREV=ORIENTATION
ORIENTATION=ORIENTATION_NEXT
if PLAYERSTATE=="ground":
ground_state(delta)
elif PLAYERSTATE=="air":
air_state(delta)
if anim!=anim_new:
anim_new=anim
anim_player.play(anim,anim_blend,anim_speed)
.
func ground_state(delta):
if btn_left.check()==2:
move(-player_speed, acceleration,delta)
ORIENTATION_NEXT="left"
anim="Run"
anim_speed=1.0
anim_blend=0.2
elif btn_right.check()==2:
move(player_speed, acceleration,delta)
ORIENTATION_NEXT="right"
anim ="Run"
anim_speed=1.0
anim_blend=0.2
elif block.check()==2:
move(0, acceleration,delta)
anim ="Block"
anim_speed=1.0
anim_blend=0.2
elif atk.check()==1:
move(0, acceleration,delta)
anim ="Attack"
anim_speed=1.0
anim_blend=0.2
elif anim!="Attack":
move(0, acceleration,delta)
anim="Idle"
anim_speed=1.0
anim_blend=0.2
rotate_behavior()
if is_on_ground():
if btn_up.check()==1:
set_axis_velocity(Vector2(0,-jump_force))
else:
PLAYERSTATE_NEXT="air"
.
func air_state(delta):
if btn_left.check()==2:
move(-player_speed, air_acceleration,delta)
ORIENTATION_NEXT="left"
elif btn_right.check()==2:
move(player_speed, air_acceleration,delta)
ORIENTATION_NEXT="right"
if get_linear_velocity().y>0:
anim="Jump_down"
else:
anim="Jump"
rotate_behavior()
if is_on_ground():
PLAYERSTATE_NEXT="ground"