#Control over character doesn't return after tween plays

1 messages · Page 1 of 1 (latest)

silk dagger
#

I'm assuming I forgot something but I have no idea what it is

limpid valley
#

What is calling climb_animation?

silk dagger
#

_process

#
    climb_ledge()```
limpid valley
#

await and tweens both run asynchronously, they can't be called from _process() or any similar function safely.

#

But if you're willing to do the hacks. The next thing i'd check here is if you have anything that sets climbing back to false.

silk dagger
#

This function is what sets climbing back to false, but it's also in _process:

    if !global_position.distance_to(target_climb) < 0.01:
        global_position = lerp(global_position, target_climb, delta * 4.0)
    else:
        target_climb = Vector3.ZERO
        climbing = false```
limpid valley
#

What is responsible for taking control away from the player? the "climbing" variable?

silk dagger
#

None of of my functions should be taking away mouse control from the player

limpid valley
#

So what is taking away control from it? From the title.

silk dagger
#

Apparently this function is:

        if event is InputEventMouseMotion and !climbing:
            if !sliding:
                rotate_y(-event.relative.x * SENS_X)
            if sliding:
                head.rotate_y(-event.relative.x * SENS_X)
            head.rotate_x(-event.relative.y * SENS_Y)
            head.rotation.x = clamp(head.rotation.x, -1.5533, 1.5533)```
#

But climbing should be going back to false at some point so I don't get why control doesn't come back

limpid valley
#

A simple and reliable solution is to make the Tween itself unset climbing once it is done.

Because atm you're relying on a condition becoming true as a result of your Tween. Which can fail.

You can tween this after your other tweeners:
tween.tween_callback(set.bind("climbing", false))

silk dagger
#

I guess I'll try that