#openable and closeable door

1 messages · Page 1 of 1 (latest)

loud plover
#

Same logic can be applied here. Instead of getting the key you open the door

steep dirge
#

ups ı deleted my message

steep dirge
#

Everything is ok in these codes, but when you press the interact button (e), the game immediately crashes and closes.

#

Game: I'm trying to make a 3D game and a door that can be opened and closed.

loud plover
steep dirge
#

how ?

loud plover
#

also, the new way of connecting signals is signal.connect(function), no need for messy strings

loud plover
steep dirge
#

Do you want me to post the code here?

loud plover
#

just did

#

wait, how do you have a Tween node?

#

which version of godot are you?

steep dirge
#

I opened it as node3d and changed its name to tween.

#

godot4

loud plover
#

there are no Tween nodes anymore

#

there is just renaming a Node3D, it does not make it a tween

#

just change your variable to var tween:Tween

steep dirge
#

But in Godot4, we cannot add tween directly from the hierarchy.

loud plover
#

then before you tween anything you do

if tween: tween.kill()
tween = create_tween()
loud plover
steep dirge
#

Do I need to write this every time, for example 13, 18,23. to the lines

loud plover
#

yes

#

you could create a function as well

#

and just call your target degree

#
func rotate_door(p_degrees):
    if tween: tween.kill()
    tween = create_tween()
    tween.tween_property(self, "rotation_degree", p_degrees, 2.0)
#

and then call that instead

#

with the target degrees

steep dirge
#

hmm okay

#

So is there a need for interact?

loud plover
#

that is up to you

steep dirge
#

Thank you for your help Thiago, my biggest mistake is that I tried to make a game in 3 days, the basic mechanics are easy, but I don't understand such things right now, so I watch tutorial videos, but they are very insufficient, I don't know how to gain this knowledge.

#

🥲

loud plover
#

you have to be sure you undersand what the code is doing

steep dirge
#

definitly