0 votes

Hi, I was wondering about how i can get an object to follow my mouse like haveing it connected to it. For my game currently, I am able to get the balloon (object) to be dragged when clicked. I would like it to connect to the mouse so when I click on my mouse the object appears where the mouse it and so that u can drag and drop it anywhere.

in Engine by (39 points)

2 Answers

0 votes

In balloon:

var is_following_mouse = false

In balloon _update():

If is_following_mouse:
    Set balloon position to mouse position

Also make when balloon is clicked set is_following_mouse to true.

If you want multiple balloons instead save the balloon in variable.

If you have different nodes you want object be in you can do this https://youtu.be/usWuBrrh5lQ

by (248 points)
edited by

Yes

var amount = 0

amount += 1
amount += 1
amount += 1
amount += 1

do you have a full code that I can just plug in for the balloon because I'm really unsure still

Send the godot project

Im not sure how

One way is to make a github.com account and make repository of your godot project and upload to there

0 votes

I made a project that make you 5 balloons.

Code:
https://github.com/Larrxi/godot-balloon-follow-mouse

Run it in browser on itch.io:
https://larrxi.itch.io/godot-balloon-follow-mouse

by (248 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories