|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
hotmailking |
I’m currently shooting a bullet towards the mouse position and I want to rotate it in that direction. It’s motion vector is calculated like this:
bullet.set_motion((get_global_mouse_position() - position).normalized())
How can I sort the rotation to be accurate to this as well?
|
|
|
 |
Reply From: |
Zylann |
You can do it like this:
bullet.rotation = (global_target_pos - bullet.global_position).angle()
Or, more simply:
bullet.look_at(global_target_pos)
There was an similar question about this:
https://forum.godotengine.org/25264/how-can-i-make-object-follow-mouse-pos
Thank you. Worked perfectly.
hotmailking | 2018-06-09 23:38
bullet.rotation = (global_target_pos - bullet.global_position).angle()
LeeJiwon | 2018-11-22 11:55
ty!
very good working
Yaroslav | 2019-11-27 17:00
1 Like