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.

Dark GDK / Monsters spin forever

Author
Message
Sephnroth
20
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 23rd Apr 2005 05:11
this is a snippet from my AI state machine. I had monsters walking around randomly fine before but that was with test code where they just instantly faced the way they were supposed to be headed and walked in that direction for a bit, even through walls.

Now I choose their next destination point taking stuff like walls into account, the destination point is set in another case statement and stored in MonsterStack[n].dx and MonsterStack[n].dz - i can confirm that they hold the correct points.

I have tried to make it so my monsters turn to face their new destination smoothly (without just suddenly pointing at it) and then walk to it. But my monsters atm are just spinning around and around forever.

Im sure im simply doing something stupid, but I cant see it XD Can any of you see the problem?



GetAngle() obviously gets the angle between two points, Diff() is a function i wrote to return the differance between two values - DiffF() is the same thing but works on floats. Incase it helps, heres the code for those:



[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
billy the kid
18
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 23rd Apr 2005 06:45
I highly recommend just reading this book: http://www.ai-junkie.com/books/toc_pgaibe.html

There is a link to Amazon on there for easy ordering. Also there is code that accompanies the book that is quite complete and you could pretty much copy/paste if you wanted to, and your AI will just work.

Anyway the book is by far the best beginner AI book I have ever read. And its really good for experts too for quick reference and new ideas. He also has written a 2nd book which goes into the more exotic AI subjects such as neural networks. But at least read this book, it talks about the "bread and butter" algorithms of game AI.

And to get a sample of his writing style, read some of the online articles on his website. His books are written exactly the same except cover many more topics.

Main page: http://www.ai-junkie.com/ai-junkie.html
Sephnroth
20
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 23rd Apr 2005 07:47
um, thankyou billy

I understand the concepts of AI though and I am running a state machine myself atm. In the past I have had cars driving around based on a nueral network and many such other experiments

For ai documentation I highly recommend the ai section of www.gamedev.net - a plethora of usful information.

But this is more about my own stupidity when it comes to implementing rotation and other such things. My monsters know when to turn and where to turn to, in that sense they are "intelligent" and I have have written "ai". But im doing something stupid in moving one angle into another and I cant spot what it is, probably becaus ei have looked at the code too long.
The problem is simple coding. My example might as well be a program which simply loads a cube and rotates it to face a certain point, its the same thing - the ai part isnt really an issue

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
billy the kid
18
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 23rd Apr 2005 08:30
Well Im saying, there is "ai move" code in the book examples and they are complete enough that you would probably just have to make a few changes. And like I said, it is the best beginner AI book Ive ever read. And a lot more helpful than anything on Gamedev even if you are an experienced AI programmer. So buy the book, get the code, and you are done. I doubt you are going to get someone to help you debug your code especially considering it isnt a "hello world" program.
Sephnroth
20
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 23rd Apr 2005 08:34
well, I dont want to seem unappreiciative, it DOES look like a good book. But im not going to (and cant afford to) buy a book to to help me solve a rotating object error XD

And no one will help me debug because its not hello world? I was under the impression this was a community help forum among other things o.O More complex problems are shared and solved in the darkbasic and darkbasic pro forums, this should be a sinch for the kind of people I expect to see in the DarkSDK board

To be honest im embarassed im even having the problem. Its really simple, I know it is. Rotating a cube is the first thing we learn in darkbasic. Making it stop when it hits a certain angle shouldnt be rocket science at all. Nothing compared to what I have had to do in the rest of my engine. So yes, im embarassed to have such a simple or "newbie" problem - but as I said I think the problem lays in me having stared at the source just far too long. Never had one of those problems where you were missing a . or had put one too many 0's on something or whatever and you couldnt spot it until someone pointed it out?
hehe

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
billy the kid
18
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 23rd Apr 2005 08:42
LOL!!! No you misunderstood my point. Your problem is not trivial. Making the AI entity move between point A and B is simple enough. Having them immediately point the correct direction is also trivial with DGSDK however not trivial from scratch. But making the entity "steer" towards a point is not trivial which you want to do. And since it is not trivial, I doubt there will be many that can help first of all. And second I doubt even if they did know, they wouldnt want to because it could get hairy like me.

So instead I referred you to a great book that explains steering behaviors in detail. You can however also look up steering behaviors on Gamedev or Google or whatever and find acceptable help. Steering behaviors really are an advanced AI subject, but at the same time they are quite simple. But only simple after you understand them properly.

So instead of trying to debug your code, Im trying to lead you to code examples that do what you want and are bug-free (supposedly).
Sephnroth
20
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 23rd Apr 2005 09:16
hehe, well thankyou I looked at the site and if i ever have any spare cash I will probably buy the book, it looks good ^^

For now however, I have fixed the problem! Turns out that my engines angle routines work at -90 degrees to the darkbasic ones, the joy! My code was -perfect- it was just using a function the calculate 90 off the mark. fixed already.

Thanks for the input

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
billy the kid
18
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 23rd Apr 2005 09:17 Edited at: 23rd Apr 2005 09:23
Well good, guess it was trivial. But how would I know that.

EDIT:
Whats the status on the image clipping? Fixed all the bugs so I can try to get the UV stuff working right?
Sephnroth
20
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 23rd Apr 2005 09:35
it was a trivial problem in a complex peice of code - imho those are the hardest bugs in the buisness to find!

I must confess I got totally swept away with this part of the code and it took my mind off clipping for a bit - now you have reminded me however I will get to work on that and get you some working code

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol

Login to post a reply

Server time is: 2023-02-02 15:22:40
Your offset time is: 2023-02-02 15:22:40