Eyes following the mouse cursor in the main menu.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Eyes following the mouse cursor in the main menu.
Okay I've been thinking, my game is kinda a psychological horror game and I wanted to remake the main menu because its a little.. bland. I have came up with an idea to make it a big image of the main antagonist with eyes following the cursor after an important thing has happened. The problem is.. I don't know how to make the eyes follow the mouse, and I can't find anything that useful on the internet, so I'm asking for help all of you. Any help is appreciated!
- m_from_space
- Miko-Class Veteran
- Posts: 978
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: Eyes following the mouse cursor in the main menu.
1. Create a screen that is also shown within the main_menu screen you will find in <screens.rpy> (or put all your code into the main menu)
2. Within that screen call renpy.get_mouse_pos() using a repeating timer of let's say 0.1 secs, which gets you the mouse coordinates
3. Calculate the vector from the position of the eyes to the mouse pos (it's actually just the difference of the x and y coordinates I think)
4. Calculate the angle of that vector and save the angle in a persistent variable
5. Use that persistent variable to define the rotation of the eyes
I hope that makes sense.
Re: Eyes following the mouse cursor in the main menu.
I will try to do that using this information, thanks!m_from_space wrote: ↑Fri Dec 29, 2023 9:44 am1. Create a screen that is also shown within the main_menu screen you will find in <screens.rpy> (or put all your code into the main menu)
2. Within that screen call renpy.get_mouse_pos() using a repeating timer of let's say 0.1 secs, which gets you the mouse coordinates
3. Calculate the vector from the position of the eyes to the mouse pos (it's actually just the difference of the x and y coordinates I think)
4. Calculate the angle of that vector and save the angle in a persistent variable
5. Use that persistent variable to define the rotation of the eyes
I hope that makes sense.
Who is online
Users browsing this forum: Google [Bot]