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
XFS Illusion
20
Years of Service
User Offline
Joined: 20th Apr 2006
Location:
Posted: 11th May 2010 02:37
This is for a space shooter using darkgdk.net, I figured I'd ask in this forum since it appears to be more active. I can easily translate the code from DBP to .net so thats not a problem.

I'm trying to figure out a good way to target other ships where if they are on the screen it will show me a square indicator around them. I can probably figure this out if I had to, but one thing i'm having a problem doing is if they target is not on the screen, a cool little arrow will point in the direction I need to go to get them on the screen. I'm messed with code using Object Screen position, but it seems to have a ghost exactly 180 degrees across from it, I hear thats a bug and i'm not sure if there is a workaround or not. Anyway, any suggestions and/or snippets would be highly appreciated.

Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 11th May 2010 04:11
I would get the player's look vector by moving the ship forward a bit, storing the new position and then subtracting the old position from the new, and then I would get the vector to the other ship by subtracting the player's position from the other's. Once you have these two, take the dot product and if the result is greater than zero, the other ship is in front of the player and if it's less than zero, behind it.

Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 11th May 2010 04:41 Edited at: 11th May 2010 04:42
well, sounds kinda like a flight sim targeting thing. Wrote a simple test using pick object, see this thread:

http://forum.thegamecreators.com/?m=forum_view&t=142740&b=1

XFS Illusion
20
Years of Service
User Offline
Joined: 20th Apr 2006
Location:
Posted: 11th May 2010 23:41 Edited at: 12th May 2010 00:28
Thanks, i'll see what I can do with this.

EDIT: This could work for me, but i'm having a similar problem. If i'm facing 180 degrees away from the target, I draws a line to a mirror image. I suppose I could use this to indicate the target is behind me assuming I only attach the target image to the object, but I wish there was a way around this. Seems there would be some 3D math that would prevent this ghost from appearing.

XFS Illusion
20
Years of Service
User Offline
Joined: 20th Apr 2006
Location:
Posted: 12th May 2010 02:19
Okay, I compensated with the the Objectinscreen command, have it set so the line only appears if the object is off screen(which is when its needed). Question, any ideas on replacing this line with a pointer image, or at the very least, shortening the line from the center? Here is the simple code(based on yours) in .NET.



Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 12th May 2010 02:26
are sprites available in DarkGDK? could you position a sprite at the target?
XFS Illusion
20
Years of Service
User Offline
Joined: 20th Apr 2006
Location:
Posted: 12th May 2010 20:17
I'm sure they are, not sure how i'd get the sprite to point at the target in 2d, though its a 3d game.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 13th May 2010 11:08
Take the 'object Screen X/Y()' commands then rotate a sprite (Or many) towards the 2d location the target sprite is located?

If that makes sense?

Place an arrow sprite in the center of the screen (for example)
Then place a sprite at the targets object Screen X/Y() position. You then have two, 2d locations with which to calculate the angle from the center screen arrow, and the target. Use the arctan (I think) command to give you an angle, then rotate the arrow sprite to this angle.

My signature is NOT a moderator plaything! Stop changing it!
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 13th May 2010 11:15
just another thought, since this is 3d, could you make another camera, position it where you are at, and point it at the target? Then, you would have rotation angles real easy for the object, you could just position the pointer to the same angles as the fake camera.
Just a thought.
XFS Illusion
20
Years of Service
User Offline
Joined: 20th Apr 2006
Location:
Posted: 14th May 2010 22:35
I can live with the draw line method after touching it up a bit, but it still points at that dang ghost object at 180 degrees from the real one. I heard this is a bug, and that there is a workaround, but not sure what the workaround is.

Login to post a reply

Server time is: 2026-07-25 23:10:29
Your offset time is: 2026-07-25 23:10:29