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 / AI Problem.

Author
Message
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 22nd Oct 2005 04:46
I'm trying to Make my cow Wander between waypoints, but He wont move towards the waypoints. Move object is only moving it in one Direction.



Any help?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Oct 2005 06:07 Edited at: 22nd Oct 2005 06:07
Your program was working - it was just moving too fast to see.

I've modified your code to do it a slightly different way because there's no way using the move command to guarantee that the 'cow' would ever be in precisely the same position as the waypoint. (You would have to alter your code to check if it was near to the waypoint).



My alterations use basically the same waypoint, but place red objects at the random waypoint positions.

You'll also see that I've replaced your block of If and then's with a single 'If CurrentFlag > 1'.

Object Hit returns the number of the waypoint you bump into and you can use this number to calculate the number of the next waypoint - and thus the element of the array to get that waypoint's X and Z location to point the cube at.

The waypoints are objects 2, 3, 4 and 5, so if Object Hit returns a 3 then we know that the next waypoint is object 4.

The cube is object 1, so if any value greater than 1 is returned then we have reached a waypoint. If the 'NextFlag' is 6 then it doesn't exist so we set it to the first waypoint which is object 2.

If you remove the Rem on line 16, the waypoints are invisible, but until you know it works, it's useful to be able to see them.

TDK_Man

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 22nd Oct 2005 15:01
Though I think instead of using "Object hit" you should check if you're a certain distance from the waypoint, because ohterwise it's a waste of polygons


TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Oct 2005 17:33
Do you mean a waste of polygons, or a waste of objects?

It depends on the size of the project really. A cube only has six faces and if your project was absolutely massive and were thinking about the effect on the framerate, you hide them anyway so they aren't drawn.

You can have up to 65535 objects and if that isn't enough (), you can always destroy any that are more than a certain distance away from you and re-use the object numbers.

I wasn't giving the 'proper' way to do it - just an easy to understand alternative.

TDK_Man

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 22nd Oct 2005 18:44
Quote: "Do you mean a waste of polygons, or a waste of objects?"


Well I ment a bit of both


Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 23rd Oct 2005 18:44 Edited at: 23rd Oct 2005 18:49
Hey Xenocythe,

Not sure what you're using your cows for, but I've written a cow-AI system for the Open MMORPG project. The code and models are available under the GPL. (Look for the thread 'WIP Cow AI'.)

Thought you might be interested? They get hungry, look for grass to eat, get thirsty and go to the water trough, get tired and fall asleep and they wander about idle when not doing any of that. I hope it can help.

[Edit] Oh, and there's documentation with the fully commented code too - just in case you're wondering what it's doing. I'm rather pleased with the documentation myself, it covers types, select/case statements and the AI state machine for the cow.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 23rd Oct 2005 19:05
Wont work with DBC... you cant hve Globals and Stuff.
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 23rd Oct 2005 20:18
Ah, so sorry. Forgot. Maybe there's something you could do to convert it, but again - I apologise if I got your hopes up. My bad
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 23rd Oct 2005 22:14
No prob tinka gal!
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 30th Oct 2005 11:04
You want Globals? Use one-value arrays.



Amazing. Now someone feed me.

Login to post a reply

Server time is: 2025-05-22 14:15:17
Your offset time is: 2025-05-22 14:15:17