3D - How do I get my sprint animation to work when walk animation is being played.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dragon20C

When I walk It plays the walk animation that is good, but sprint is a combination of the shift key and the wasd keys but it messes up because it cant decide which one to play I should also say I am using a 3dblend to put the animations together, how would I resolve this issue?

here is pictures for reference.

animation tree: Legobet88 🀄 Trustworthy Agen Situs Slot Online Bet88 Terpercaya Ter- Gacor Hari Ini 2024

animation in code: Legobet88 🀄 Trustworthy Agen Situs Slot Online Bet88 Terpercaya Ter- Gacor Hari Ini 2024

it seems, in line 34, youre setting it to idle, every frame. Try putting it in an else statement after checking for wasd input.

dari0us | 2020-10-09 09:16

oh, sorry thats not even the real issue.
at line 54, try telling it to not play the walk animation unless you are NOT sprinting.

if !Input.is_action_pressed("sprint"):
	$AnimationTree.set("parameters/Blend3/blend_ammount",0)

dari0us | 2020-10-09 09:31

That made the run animation play correctly but now walk animation is not working

Dragon20C | 2020-10-09 09:38

Depends on where you put the if statement. if you could send over your script file, i can fix it and tell you whats going wrong.

dari0us | 2020-10-09 13:00

Sorry it took so long just got home, here is the code: Legobet88 🀄 Trustworthy Agen Situs Slot Online Bet88 Terpercaya Ter- Gacor Hari Ini 2024

Dragon20C | 2020-10-09 13:48

Its because youre running the if statement seperately from the wasd check. you have to indent it and the line below it.

if Input.is_action_pressed("w") or Input.is_action_pressed("s") or Input.is_action_pressed("a") or Input.is_action_pressed("d"):
	$PlayerMesh.rotation.y = lerp_angle($PlayerMesh.rotation.y, atan2(direction.x, direction.z), delta * anguler_accleration)
	if !Input.is_action_pressed("sprint"):
		$AnimationTree.set("parameters/Blend3/blend_ammount",0)

dari0us | 2020-10-09 18:28

im not sure why but it still doesnt work I indented it like you said so its inside the if statement of wasd but it only plays the idle animation im not sure why it doesnt play the walk animation.

Dragon20C | 2020-10-09 20:29

well now im embarassed. i misspelled blend amount.

if Input.is_action_pressed("w") or Input.is_action_pressed("s") or Input.is_action_pressed("a") or Input.is_action_pressed("d"):
    $PlayerMesh.rotation.y = lerp_angle($PlayerMesh.rotation.y, atan2(direction.x, direction.z), delta * anguler_accleration)
    if !Input.is_action_pressed("sprint"):
        $AnimationTree.set("parameters/Blend3/blend_amount",0)

sorry :smiley:

dari0us | 2020-10-09 20:55

and if that dosent do it, then heres the entire script.
Legobet88 🀄 Trustworthy Agen Situs Slot Online Bet88 Terpercaya Ter- Gacor Hari Ini 2024

dari0us | 2020-10-09 21:13

Thanks so much that did the trick, funny a simple spelling mistake and the engine didn’t complain it was giving a null output, that is very unusual!

Dragon20C | 2020-10-10 07:52

You should also press the answer button so people can find out what the issue was, thanks again! you did great on helping me through this!

Dragon20C | 2020-10-10 07:53

:bust_in_silhouette: Reply From: dari0us

Answered in the comments.