Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Captain Chucky
14
Years of Service
User Offline
Joined: 5th Feb 2012
Location:
Posted: 5th Feb 2012 09:36
I've been working on a space shooter for some time now, and I spent most the day trying to figure out a radar system. I've looked at snippets, tried various types of code, and just don't know where to get started on what i'm looking for.

What I want is a small 3d transparent or wireframe sphere that comes up when I press the "Radar" key. My ship will be in the center of the sphere, all other players (This is multiplayer) and objects will show inside the sphere around me. As my player rotates or tilts, the objects inside the sphere move as well. I've tried the overhead cam idea and it just isn't want i'm looking for. Also tried the "Elite" 3d radar snippet, and it puts too much drag on the program.

I have a function that can determine the distance an object is from my player, and if need be I can figure out which direction it is in in relation to my player with a dummy object or mathematically, but I have no idea where to go from there. I already plan to loop through the objects, so that isn't a problem. I'm willing to settle for 2d Radar if I can find one that's not too bad on resources and allows me to see objects around me as blips. I'll be toggling this radar on and off if that makes any difference. Any help and/or code would be appreciated.

Thanks in advance.
Millenium7
21
Years of Service
User Offline
Joined: 13th Dec 2004
Location:
Posted: 5th Feb 2012 17:14
shouldn't be too difficult to do but I can't think of the exact commands in my head right now so can't give you an example

The way I would do it is firstly define a radar range (it being radius not diameter), then check for any objects within that range all around you

Use 3dmath commands to find their angle and distance from you. You now have what you need to construct either 2d or 3d (though with 2d you might be better off checking radius on the X/Z axis, and larger range on the Y, i.e. a cylinder instead of sphere)
Once you have the range and angle from you then I imagine a 3d radar would be rather easy, merely create a new plain for each object within range and then position them to a central 'radar object', just divide the distance factor by 250 or whatever

The 2d side would be much the same except you ignore the height axis and use sprites/2d commands
Captain Chucky
14
Years of Service
User Offline
Joined: 5th Feb 2012
Location:
Posted: 5th Feb 2012 22:49
Figuring the distance is no problem, already have a built in function for that. Anybody know off hand how to get the angle? If I created a dummy cone and pointed it to the object, could I just get the angle from it? If anybody has any sample code on this, it would be greatly appreciated.
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 5th Feb 2012 23:03 Edited at: 5th Feb 2012 23:13
I think this is doable with unit vectors as well, and you wouldn't even need to create an actual vector. You could just do the following:

1) Pick a range for your radar.
2) Pick a radius for your radar sphere.
3) Do a for/next loop through all of the other players, and do the following:


Pseudocode:



EDIT: Hmmm... I assumed the radar was centered at the camera. If you want to move it then just change Camera Position X()/Y/Z to wherever the center of your radar sphere is. This could make the tilting part a little tougher though.

I haven't tested this, but I think it should work.


Guns, cinematics, stealth, items and more!
Captain Chucky
14
Years of Service
User Offline
Joined: 5th Feb 2012
Location:
Posted: 6th Feb 2012 01:18
I would love to do it Sixty's way, but I have no idea how to put the objects within the radar sphere, maybe i've just been at it too long. On a side note I tried the following code, not bad for 2D radar but whenever I flip my ship around the object on the radar doesn't reverse most the time. Though sometimes it shows up as being behind me as it is supposed to, strange. Probably an error in the math somewhere, would probably do fine on a plane.

JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 6th Feb 2012 03:20 Edited at: 6th Feb 2012 03:34
If I were programming this, I would simply take the x, y, z coordinates of all of the objects and scale them to fit within the sphere, using my "ship" as the center point from which all other coordinates were calculated.

This is a fairly easy approach and could easily duplicate the "radar" you are asking about, without a lot of tricky math or functions.

Then point a second camera at the "radar" group.
JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 6th Feb 2012 03:48
But be aware that this consumes resources (additional objects, object tracking, new calculations, etc.). However, any type of 3d radar will consume resources and this may be the least resource expensive.
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 6th Feb 2012 04:18
Quote: "I would love to do it Sixty's way, but I have no idea how to put the objects within the radar sphere, maybe i've just been at it too long."


The XV#, YV# and ZV# variables in my code above are meant to be the object's position within the radar (works best if the radar is centered at the camera)...

Are you using 2D or 3D markers for your radar? If you're using 2D ones then you could try positioning a dummy object at XV#, YV#, ZV# and then using OBJECT SCREEN X/Y to position the dot.

A 3D solution might be to just use 3D plains pointed at the camera, positioned at XV#, YV#, ZV#.

Or perhaps I'm misunderstanding what you're trying to do here?


Guns, cinematics, stealth, items and more!
Captain Chucky
14
Years of Service
User Offline
Joined: 5th Feb 2012
Location:
Posted: 6th Feb 2012 04:35
You understand well, I think i'm the one who's getting confused lol
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 6th Feb 2012 05:46
Well which part are you confused about? lol


Guns, cinematics, stealth, items and more!
Captain Chucky
14
Years of Service
User Offline
Joined: 5th Feb 2012
Location:
Posted: 6th Feb 2012 06:09
So your saying I create a sphere, attach it somewhere on my screen and then fill it up with my objects?
Millenium7
21
Years of Service
User Offline
Joined: 13th Dec 2004
Location:
Posted: 6th Feb 2012 07:33
Quote: ". Anybody know off hand how to get the angle? If I created a dummy cone and pointed it to the object, could I just get the angle from it?"


point and check angle would work however i'm pretty sure there'd a 3d math command to do it...

atanfull() should also work i.e.
angle1# = atanfull(x2-x1, y2-y1)
angle2# = atanfull(x2-x1, z2-z1)
angle3# = atanfull(z2-z1, y2-y1)

i'm too tired to work out which is what, but I believe that should give you Y, X and Z angles between points. It's only checking 2 dimensions at one time but I can't see why that would be a problem
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 6th Feb 2012 15:32 Edited at: 6th Feb 2012 15:33
umm... how about ising thr sphere as a single entity placed within view and ray cast every few ms maybe 500 ms and aim the casts at other players and pinpoint these on the sphere if that makes any sense... [not sure how this would impact performance...

just my thought so far...

[EDIT

oh and the ray casts would be from the centre of the sphere of course... and perform a colission check with the sphere and position a dot there... maybe lock the sphere at scheen width -25% and screen height - 75% [top right of the screen if you get me-or where ever you choose...] let me know if this ever gets implemented would love to see how its done...

EDIT

and'

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 6th Feb 2012 15:50
If you just scale X/Y/Z down everything is solved.

Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 6th Feb 2012 18:34
Quote: "So your saying I create a sphere, attach it somewhere on my screen and then fill it up with my objects?"


That depends on what you are trying to do. If you are trying to make a 3D spherical radar, at the center of which is the player (or the camera), then the code I posted should give you the positions of all the other players within your radar sphere.

The whole thing about "Radar Objects" was just my guess as to how you want to visually represent the objects on your radar. Sure, all the other players have a 3D ship model that the player can see floating around in space, but you'd want them to show up as a little dot or something on your 3D radar too right? To represent them as a dot, you have to actually put something where the dot should be. For example, you might make a bunch of green dot objects to represent other players and then position them accordingly within your radar. It's up to you, but the code I gave should tell you where those dots should go.


I'm assuming that your radar is a giant sphere around the player's ship, and that your game is a first person or a close third person game. If you want a small radar in the corner then my code should still work, but the tilting/rotating could get a little more complicated.


Guns, cinematics, stealth, items and more!
Captain Chucky
14
Years of Service
User Offline
Joined: 5th Feb 2012
Location:
Posted: 7th Feb 2012 02:13
It has a cockpit view, though putting it in the center might be good if i activated it with a hot key (so user has an option to improve FPS). Otherwise i'll put it off to the side. I'm going to play with the code some more this evening, thanks for all the help guys. I'll be checking back with this thread in case anybody has another brainstorm.
Sixty Squares
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 9th Feb 2012 06:00
Alright, sounds good. I imagine the tilting/rotating would be easier with the cockpit view, but if you don't care about that then it shouldn't make a difference which option you chose. Good luck and let us know if you run into any more problems!


Guns, cinematics, stealth, items and more!

Login to post a reply

Server time is: 2026-07-11 14:37:48
Your offset time is: 2026-07-11 14:37:48