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.

DarkBASIC Discussion / A trageting system

Author
Message
Bob_42
19
Years of Service
User Offline
Joined: 15th Sep 2006
Location: Guernsey
Posted: 27th Sep 2006 20:09 Edited at: 28th Sep 2006 18:44
how can i create a targeting, i'm not asking for code (although i don't mind you giving me some ) i just want some ideas...

i was thinking of somehing like, if the enemy came within the range it would auto-target it (i.e an aiming sprite would go to the position on screen) and if there were multiple enemies the player could scroll through the targets by pressing a key on the keyboard, what would be the easiest way of doing this?

Bob_42
19
Years of Service
User Offline
Joined: 15th Sep 2006
Location: Guernsey
Posted: 28th Sep 2006 01:50
*update*

i had a quick go, and as i thought, i can easily make a target come up and when you press space it moves to the next object, however this would cycle through every object, so how can i define whether an object is an enemy, ally or other (weapon, etc.) and how can i return a result if an object is within a certain distance of the character?

p.s. sorry for the bad spelling in the last post, i think i am just tired (and it won't let me correct it, i assume its something to do with forum not letting new member use all the functions)

anyway thanks in advance

Krilik
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Arizona, USA
Posted: 28th Sep 2006 06:42
In order to check whether the object is an enemy or not just make an array and store the object number in a variable and then a 0 or 1 into another variable. 0 is not an enemy, 1 is an enemy.

And when you press spacebar is cycles through the object numbers stored in the array, and returns whether or not its an enemy.


To check distance you'll need this formula.

distance = sqrt ((x1-x2)*(x2-x1)+(y1-y2)*(y2-y1)+(z1-z2)*(z1-z2))

You'll need to check the distance of every object to the player every loop. Which seems like a really insufficient way of doing it. I'd look into it a little bit more for you except I'm very very tired, and need to get come work done before I hit the hay.

Hope this helps.
Bob_42
19
Years of Service
User Offline
Joined: 15th Sep 2006
Location: Guernsey
Posted: 28th Sep 2006 18:43 Edited at: 28th Sep 2006 19:07
hmm, i can't seem to get that to work...

i assume X1,y1,z1 are the cordinates of the human controlled character and x2,y2,z2 are the enemys position...

one other thing i assume right at the end where it says "(z1-z2)" it should be the other way around, "(z2-z1)"..

it doesn't work for me, i keep getting the value of 0

EDIT: never mind i fixed it

Login to post a reply

Server time is: 2026-07-08 08:52:47
Your offset time is: 2026-07-08 08:52:47