| We hope you enjoy your visit. You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you are already a member please log in to your account to access all of our features: |
| GML question; instance_nearest and health > 0 | |
|---|---|
| Tweet Topic Started: Dec 22 2012, 01:11 AM (169 Views) | |
| RonBurgundy | Dec 22 2012, 01:11 AM Post #1 |
|
Forum Borat
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Hit another brick wall. Yet again it's AI related. Basically what I'am aiming to do is is find the nearest instance of an ally with a health value of greater than 0 for the enemy bots. Right now the bots just use Target = instance_nearest(x,y,parentObject) to find a target. However, when the target's health is < 0 is doesn't just destroy itself. I use SetModelMaterial to gradually fade it away until it is no longer visible and then destroy it. While this is happening, the bot still recognizes the closest ally(the one with health < 0) as the target while there are other allies shooting at it. I've been scouring the GMC for a solution, and found a few scripts like... instance_nth_nearest(): Spoiler: click to toggle Cant see how I could make it work. I was thinking about using a for loop to change the ID's but that may be a headache. There was also an extension that would have been useful if it wasn't corrupted that would have done exactly this. Any help is appreciated. Edited by RonBurgundy, Dec 22 2012, 01:12 AM.
|
| !!! DEFEND POP PUNK !!! | |
![]() |
|
| Despellanion | Dec 22 2012, 01:35 AM Post #2 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
So your problem is that the allies still recognizes the other ally while it is fading? Can't you just check if the ally's alpha == 255 while it also check if health > 0? |
![]() |
|
| RonBurgundy | Dec 22 2012, 01:43 AM Post #3 |
|
Forum Borat
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Kinda. But it's the enemy bot that still recognizes the ally bot even when its health is at 0. The enemy only targets the ally that is closest. Lets say it kills that same ally. instead of targeting the next closest ally it moves to its next pathfinding node, UNLESS another ally bot is closer than the dead one thats fading. Because the ally it just killed is still closest. What I have now is something like: Tar = instance_nearest(x,y,objBotAlly)//objBotAlly is the parent for all ally bots. if Tar.hp > 0 and inFOV = true { yadayada raycasting stuff } |
| !!! DEFEND POP PUNK !!! | |
![]() |
|
| Reikyrr | Dec 22 2012, 02:59 AM Post #4 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
it probably is tooo late for that already but I would make a central bot instead of enemy and ally then keep track of the team inside of it. then you can make rules on how bots should act against other teams. that way if a bot dies you just set it to a team that does not get any attention. as for targeting I would first use a bounding box or grid to determin which bots are close. |
|
~Inspirational quote~ | |
![]() |
|
| RonBurgundy | Dec 22 2012, 03:21 AM Post #5 |
|
Forum Borat
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Thanks for the advice. Isn't using Bounding Box for the camera though, or do you mean a different bounding box? I do want to stay away from grids, just trying to keep things cheap and fast. EDIT: nevermind figured out a solution thanks! Even more off topic: Got a new headset microphone for my computador, be starting U3D titorials for GM again sometime this week |
| !!! DEFEND POP PUNK !!! | |
![]() |
|
| Reikyrr | Dec 23 2012, 08:34 PM Post #6 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I just mean the math side.
|
|
~Inspirational quote~ | |
![]() |
|
| « Previous Topic · Off-topic · Next Topic » |





![]](http://z1.ifrm.com/static/1/pip_r.png)



2:40 AM Jul 11