|Topic was automatically imported from the old Question2Answer platform.
I have set up my player’s script to move him to the other side of a door after opening it. The type of movement I have chosen for the project is point and click. There is an area with a collision shape (toggled by clicking on it) on the door that, when a body enters it, triggers a sort of “cutscene” of the character opening the door.
However, after the animation finishes he just goes back to where he was going to before. I think that the click to move function stores a position and, after the animation finishes, it resumes it’s purpose.
I have tried to set conditions at the beggining of every function of the character to return if a cutscene is active, and that works while the cutscene is active but once it finishes it is as if those functions had never stopped.
If necessary I will post the click to move part of the script, otherwise here’s the cutscene part:
if body.name != "David":
if Disable_IAB == false:
Cutscene_state = true
translation = Vector3(-1.186, -0.127, 3.8) #this is to set the player's position to the animation's starting point
rotation_degrees.y = -90
play_anim("Open Door back")
translation = Vector3(0.5, -0.127, 3.8) #this is to move the character to the other side of the door
rotation_degrees.y = -90
Disable_IAB = true
Cutscene_state = false
Disable_IAB - disables the interaction collision box of side B of the door
Cutscene_state - Indicates if a cutscene is active or not
_on_InteractAF_body_entered(body) - detects collisions on front box
_on_InteractAB_body_entered(body) - detects collisions on back box
I must also say that I have attempted to turn off the cutscene right after the end of the animation but the result is the same. I then set it to end the cutscene once the character touches the box on the other side of the door (front side in this case) but the only difference is that there is a split second in which the character is on that side before resetting back to where he was.
Why don’t you reset / change the destination of the click to move function to the final position?
exuin | 2022-12-09 04:47
My intention is to have the character automatically on the other side instead of walking there because the animation ends with him on the other side. If I set the final location as that, he will still start where he was before but walk to the other side of the door.
I’m not sure how to reset the destination that is “stored”, i’ve tried to set the condition of if Cutscene_state == false return on both the beggining of the function and the end but it doesn’t affect it.
EDIT: I have solved the issue by using set_process(false) at the end of each function. Apparently that resets everything.
DiAlEx | 2022-12-09 10:13