Ive been trying for 3 days now and cant get it fixed any help ?
Thx
Im having troubles with rotating a gun towards the mouse, any help?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Im having troubles with rotating a gun towards the mouse, any help?
- Attachments
-
- prototype.love
- Love file (the game)
- (4.14 MiB) Downloaded 97 times
-
- anyonehelppls.lua
- Its gun.lua btw i just renamed it
- (501 Bytes) Downloaded 91 times
- BrotSagtMist
- Party member
- Posts: 661
- Joined: Fri Aug 06, 2021 10:30 pm
Re: Im having troubles with rotating a gun towards the mouse, any help?
Code: Select all
love.graphics.draw(gunsprite, px, py, -math.atan2(635- love.mouse.getX(),360- love.mouse.getY() ) +math.pi/2 , 1.3, 1.3, gunsprite:getWidth(), gunsprite:getHeight()/2)
This huge translation will bite you in the ass later on, i do not recommend it.
obey
Re: Im having troubles with rotating a gun towards the mouse, any help?
You need to convert the mouse position from screen coordinates to world coordinates before you can calculate the difference to the player for use in atan2(). It looks like the camera library you're using has a relevant function: camera:mousePosition().
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."
Re: Im having troubles with rotating a gun towards the mouse, any help?
Ty all so much for the help !
Who is online
Users browsing this forum: Bing [Bot] and 5 guests