|
Help with Trigonometry
#471963
03/29/18 03:06
03/29/18 03:06
|
Joined: May 2005
Posts: 868 Chicago, IL
Dooley
OP
User
|
OP
User
Joined: May 2005
Posts: 868
Chicago, IL
|
I am making a top down map, icons appear on the map to help the player find important locations. When the player is near them, it's easy to position them on the map. However, when the player goes away a certain distance the icon will disappear off the edge of the map. You can see the player is represented by an arrow, and the landing craft is represented by a bright green spaceship icon. What I would like to happen is for that icon to stay on the map, just on the edge, at the paint between the player and the location indicated by the icon. I have some basic understanding of the trigonometry involved in doing this, but I am way out of my comfort zone. My calculations kind of work, but they are not really accurate, they tend to move in the direction opposite of where they should. This code is included in the icon's while loop: while(level_loading == 0 && planet_character != NULL) { you = ptr_for_handle(my.skill2);//pointer to actual game object/location my.x = you.x;//positions itself directly over object at height 1000 my.y = you.y;//positions itself directly over object at height 1000 //check if player is more than 300 quants away if(vec_dist(vector(you.x,you.y,0),vector(planet_character.x,planet_character.y,0)) > 300) { u_v_mult = (you.x * planet_character.x) + (you.y * planet_character.y); mag_u = sqrt((you.x * you.x) + (you.y * you.y)); mag_v = sqrt((planet_character.x * planet_character.x) + (planet_character.y * planet_character.y)); my_theta = acosv(u_v_mult/(mag_u * mag_v));//gets the angle my.x = planet_character.x + (300 * (cos(my_theta))); my.y = planet_character.y + (300 * (sin(my_theta))); } my.pan = planet_character.pan; wait(1); }
The edge of the map is roughly 300 quants away from the player, so that's when the icon needs to start "floating" between the player and it's actual location. Also, it is causing a crash when the player moves too far to in the negative (x,y) as compared to the icon. Any help would be great! I'm sure there are built in functions/commands that might make this easier, but I really have trouble with this kind of stuff. Any advice would be appreciated!
|
|
|
Re: Help with Trigonometry
[Re: Dooley]
#471966
03/29/18 12:21
03/29/18 12:21
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
what is your minimap setup? is it a panel or another 3d view?
3333333333
|
|
|
Re: Help with Trigonometry
[Re: Dooley]
#472002
04/01/18 10:51
04/01/18 10:51
|
Joined: Mar 2014
Posts: 359
CocaCola
Senior Member
|
Senior Member
Joined: Mar 2014
Posts: 359
|
interesting feature. i have problems if mag_u * mag_v is 0 so i have make it so
i=(mag_u * mag_v);
if(i!=0)
i=u_v_mult/i;
my_theta = acosv(i);//gets the angle
the feture is like the 2d points on a screen in space simulators, but how you stop the green square symbol, not go out the screen in the ages of the map? can you give me a example in an existig game where i can see the let's play. And Sorry for the complicatet Engish
|
|
|
Re: Help with Trigonometry
[Re: CocaCola]
#472005
04/01/18 11:55
04/01/18 11:55
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
the points on the map not show the distance. they only stay on the border to show where to go to arrive the location. That is exactly what my code does...
|
|
|
Re: Help with Trigonometry
[Re: txesmi]
#472006
04/01/18 15:00
04/01/18 15:00
|
Joined: Mar 2014
Posts: 359
CocaCola
Senior Member
|
Senior Member
Joined: Mar 2014
Posts: 359
|
oh sorry, i must test it. because is it vector? is it lite-c? that is cool
Last edited by CocaCola; 04/01/18 22:05.
|
|
|
Re: Help with Trigonometry
[Re: CocaCola]
#472009
04/01/18 19:29
04/01/18 19:29
|
Joined: May 2005
Posts: 868 Chicago, IL
Dooley
OP
User
|
OP
User
Joined: May 2005
Posts: 868
Chicago, IL
|
Thank you guys for your help! When I mentioned I think I came up with a much easier way to handle this. I did not think anyone would continue to work on this problem. I ended up having two different objects, one that appears directly over the target, and one that is attached to the player. When the target object goes outside of the range, in this case 400 quants, then it disappears, and the other one, attached to the player appears. The object attached to the player is a model with the the image exactly 400 quants from the center. All I had to do was set its pan to the direction of the target, and it automatically points in the right direction. You can see it in action in my video: Top Down ScannerWhen the circular targets turn into arrow pointers, that actually is a different object appearing, while the target disappears. It's crude, but it works.
Last edited by Dooley; 04/01/18 19:29.
|
|
|
|