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 Physics & Dark A.I. & Dark Dynamix / DP & DAI help needed

Author
Message
sindore
20
Years of Service
User Offline
Joined: 2nd Jul 2004
Location: Bedfordshire, UK
Posted: 15th Sep 2009 20:32
I was looking throe this darkAI Documentation to see if there was an example of how darkAI and dark physic worked together, and come across this.

Quote: "Compatibility With A Physics System

The main issue with combining DarkAI with a physics system, such as DarkPhysics, is that physics will also want to control the DarkBasic objects representing your entities to stop them moving through each other. If you link the objects with the AI system with the physics system trying to move them conflicts may arise between which position the object should be moved to. The solution to this is to give control of the object over to physics as normal and to not link the object to the AI system, instead using the Set Position and Get X/Z commands to change and retrieve the entities' positions.

If the physics system can detect when an object is re-positioned and update its internal values then the two systems should work together as long as AI Update is called before updating physics. This avoids the possibility that after physics has prevented collisions the AI moves the entity into a new collision. If this is not the case then you can remove the AI system from controlling the entity and use the physics system to position the entity where the AI wants it to go.

When not linked to an object DarkAI will use internal values that represent where it thinks the entity should be when AI Update is called, use AI Get Entity X and AI Get Entity Z commands to get these values. You should then use methods provided by the physics system to move the DarkBasic object to this position, for example using forces, velocities or positions whichever the physics system prefers, and let the physics system move the DarkBasic object. Then update the physics system so that it positions the DarkBasic object for you and adjusts for collisions, etc, automatically. Then get the new position of the object using the normal DarkBasic commands Object Position X and Object Position Z and use the AI Set Entity position command to set the new internal position for DarkAI to work with. This new value will then be used by the AI system in the next AI Update to work out where it wants the entity to move to, it stores these new values internally and the cycle repeats. It is recommended you always update the AI before you update the physics in your loop.

You can use AI Set Entity Collide to tell an entity when it is blocked by something it doesn't know exists (a physics object that is not an obstacle in the AI system) which the AI would constantly try to move through and physics would keep stopping it. This tells the entity to move sideways for a bit."


can any one give me an example of what this is on about? in code or just small hits to help me out would be helpful.

thanks in advance

soul sucking devils, twisted body of the damed, slivering slim drips from every poor, sin licking at your ears, and the smell stinging your eyes, and if you don't like it, get out of my kitchen!
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 16th Sep 2009 13:30
I have tried alot of ways, the CC (Character Controller) object both linked and not linked to the Ai entity. I had some intermitent crashing when linking the Ai to the CC using "AI Set Avoid Mode 0" (worked on mode 3), crashes happening when rotating the CC.

I now use an interpretation of the non linked way as the help information file describes.
I set the entity as non linked with:
AI Add Enemy ID , Mode[, Container]
Mode=1 linked to object ID
Mode=0 not linked, just use ID as the reference.
The ID can be the same object as the CC though.

Then i have a physics CC object as the underlying hidden player object and a model at the same coordinates as the CC.

Every timestep i track the position (Get Entity X,Get Entity Z) of the entity and the position of the CC object,
then point the CC object to the Ai entitys coordinates.
- If the distance between the two is within a tolerance value i use the distance to assign the speed of the CC and move it towards the Ai entity (the CC works like sort of a trailer pulled by a car, following the Ai entity).

- If the distance is greater than a set value (depends on every games scale) i assume the CC trailing object has hit an object and stuck, then move the Ai Entity position back to the CC's coordinates and set the AI collide. If obstacles are setup the Ai entity will seldom move too close to them for this to happen. If it happens the "Ai set entity collide" will set the entity in a mode of avoiding, do not however assign the entity to any other ai move command during the avoid sequence, and have some special code to make the Ai move around very stubborn unassigned obstacles.

- Finally i get the Ai Entitys angle and rotate the model to this angle, note; the characters (model) view/fire angle is _not_ the CC objects angle, this way it can strafe correctly.

Have some test code i used when prototyping this, i'll look for it.

Regards
sindore
20
Years of Service
User Offline
Joined: 2nd Jul 2004
Location: Bedfordshire, UK
Posted: 16th Sep 2009 16:06
thanks, just out of interest do you have any code snip-its?

just an example of what you have done would help a tone, will test out what you have said already tonight.

soul sucking devils, twisted body of the damed, slivering slim drips from every poor, sin licking at your ears, and the smell stinging your eyes, and if you don't like it, get out of my kitchen!

Login to post a reply

Server time is: 2024-11-24 17:27:39
Your offset time is: 2024-11-24 17:27:39