I feel like I should know how to do this, and I did get this working (unfortunately with negative side affects), so I was wondering if anyone had an approach they would suggest on how to make a character skid when moving a certain direction and then inputting the opposite of that direction? (like if Mario turns around while running)
It's a top-down 2D character, and I have the method to apply friction, I'm just looking for the right words to specify to apply friction when inputting the opposite direction the character is moving. Basically I'm trying to word the condition right.
This is what I came up with:
if velocity.x >0 and Input.is_action_pressed("ui_left") or velocity.x <0 and Input.is_action_pressed("ui_right"):
apply_friction(_delta)
if velocity.y >0 and Input.is_action_pressed("ui_up") or velocity.y <0 and Input.is_action_pressed("ui_down"):
apply_friction(_delta)
,but is there a better way I should or could word this? (Preferably shorter so I can declare "apply_friction()" once instead of twice.)
Anyway, I'm struggling with something I feel should be more simple, even for me, but I'm still a novice, so I thought I'd ask for help. Thank you.