Hi everyone,
I'm very new to using both LOVE and Lua, and so I was wondering how I would go about making the player rotate towards the mouse cursor inside of my game. Any help is appreciated.
Making the player rotate towards the mouse cursor
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Making the player rotate towards the mouse cursor
Do you have any code that draws your player?
You can copy/paste and we'll see if we can help.
You can copy/paste and we'll see if we can help.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/pad-and-pencil-gridiron
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/pad-and-pencil-gridiron
Re: Making the player rotate towards the mouse cursor
Use math.atan2() to get the angle between two points.
You could also look at this other recent thread: viewtopic.php?f=4&t=93566
Code: Select all
local angleFromPlayerToMouse = math.atan2(mouseY-playerY, mouseX-playerX)
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Who is online
Users browsing this forum: No registered users and 5 guests