Hi! I need help with some code!

Versions 4.2.2

Hi! I’m using Godot 4.2.2 and I’m having trouble with my game.

Basically I want my character to be able to move by themselves, like an NPC. This is a Pet Sim game, so I also want to be able to drag them all over the place as well, just as a cute little thing to do.

I got the code for the Drag and Drop function, I used a version of someone else’s code, along with some other modifications.

Here’s the pastebin! code for drag drop - Pastebin.com

It’s connected to a RigidBody2D node.

This is a WIP of the room so far, I got it so you can’t drag them past the room, However, when I drop them, the animation stays as if they’re still being dropped, even though they’re on the ground. I’m wondering if there’s a way to detect that?

I’m wondering if it’s even possible to have them walk around on their own? All the tutorials I looked at use Kinetic or something else. So I’m wondering if I’m even on the right track.

Thanks in advance!

Did you made a condition for it to go back to idle?

I notice you play a “dropping_idle” animation, maybe you can add a automatic transition from this animation to the regular lidle one?

If it’s an AnimationPlayer, select “dropping_idle”, then click on the Animation button in the panel and select “Edit Transitions”, pick idle as the “Next (Auto Queue)” animation.

If it’s a AnimatedSprite2D you will have to connect to the “animation_finished” signal, then play “idle” on the connected function, kind of like this

func _on_minii_anims_animation_finished() -> void:
    if anim.animation == "dropping_idle":
        anim.play("idle")

Ooh! I’ll try this out, thank you!

No, that’s what I’m trying to figure out! Someone replied giving me a method how, so I’m trying that out. Thank you!

It works!!! Thank you!

Oh ok but if you decided to make more animations I recommend looking into animation tree it might be overwhelming at first but it deserves the pain👍

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.