@ZachSaucier thank you for your answer.
I'm not at ease with quickSetter since it might be to hard for my level (even if I understand why it's useful).
I hope you or someone could help me with a GSAP solution to achieve this scenario :
A fish asset follows the mouse position and the fish asset always points toward the mouse.
It's a basic effect, I already saw some examples but it sometimes hard to translate from jQuery and I would like to avoid it.
I read some articles and Codepen exemples and I think I understood the logic (I already achieved the object following the mouse) :
- Calculate the center position of the asset (Can I get the center position? Or I need element.width/2 etc. ?)
- Calculate the vector from the center of the asset to the mouse position
- math.atan2 magic and convert from radians to degres (But I don't get which values are used ? Is it something like (mouse.x - element.centerX, mouse.y - element.centerY ) ?
- Use the variables that results as the rotation
Is my scenario correct?
I'm a not a big coder and I have notion, I would like to do it the more classic way (no jquery for example).
https://codepen.io/charlesbail_/pen/oNzWzov
(the code is a non sense and I'm working on it, but just so you know I've started)
Also in this file, there is the use of the (e) element. I'm reading some articles related to events but that's a bit of abstraction to me. I'm trying to write it in "plain" javascript even if requires more typing. It's clearer for me.
I thank you in advance for your time to help me understand
Charles