![]() |
Need some help..
Im not so good at math so i cant figure this one out, here goes.
I am trying to make a npc that shoots a projectile towards the mousex and mousey, but i cant figure out how to get the angle to work. Im trying to get the angle of mousex and mousey so the projectile will shoot towards the mouse position, i can figure out how to use power but i cant figure out the angle part, any help would be appreciated.. Thanks |
getangle( dx,dy ) - the angle of vector (dx,dy) to the x coordinate (0...2*3.14)
Just subtract the player position with the mouse position. |
I wish I could find the power..
I've tried all different equations and none of them work. |
...
dx=mousex-playerx; dy=mousey-playery; angle=getangle(dx,dy); btw u might want to change dx and dy so its from the center of the mouse and player but that's the concept =) |
Quote:
|
and you could use the basic distance calculation to make the projectile land where you click
(((playerx-mousex)^2)+((playery-mousey)^2))^0.5 I think. |
I'll try that and see if it works.
|
NPC Code: I'm phat. :) |
Quote:
Looks nice :) |
| All times are GMT +2. The time now is 02:01 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.