Sign in to follow this  
Cacks

User & AI character movement Plumbing

Recommended Posts

Cacks    179

HI Guys,

 

I am using MVC design pattern in my game

 

I fire an Event that contains the Force that will be applied to get my character to move it

 

Is this the correct way to do this?

 

If so is this the same technique my AI should use to move it's characters?

 

cheers

Share this post


Link to post
Share on other sites
Ashaman73    13715

I use a similar approach in my game (MVC + "force" ). The controller (either player input or AI) would use the same model (force) to move (physics controller) the entities.

 

Just one thought, you spoke about force. This would usually result in a dynamic movement controller (entities which are moved by the physics engine). The other way to move an entity is to use of a kinematic controller (entities are moved directly, without physics, the physics engine is only used for collision detection). Both have advantages and disadvantages, but a simple kinematic controller is in my opinion an easier way to control the entites the way you expect them to move. Eg moving humanoid entities with a dynamic control could be very frustrating. If you want to save some time and nerves try to do some research in kinematic vs dynamic movement controllers.

Share this post


Link to post
Share on other sites
Cacks    179

Hi Ashaman73,

 

cheers for your feedback

 

I need to send in Force as I am modelling Friction in my game & am doing proper physics calculations

 

Does this make it difficult to program the AI? I haven't programmed AI before,

 

cheers

Share this post


Link to post
Share on other sites
Ashaman73    13715

Does this make it difficult to program the AI? I haven't programmed AI before,

It depends on what kind of entity you want to steer and what kind of goal you want to archieve. A spaceship or car is steered in an other way, then a precise moving human who needs to jump from platform to platform. The first kind of entity is really suitable for a dynamic controller, the latter is really hard.

 

 

 


I need to send in Force as I am modelling Friction in my game & am doing proper physics calculations

Do you need proper physics calculation ? Do you have rigid bodys (car, boxes, spaceship) or softbody (human) ? Can you switch between physics calcution and direct control (AI/player controlled => use kinetic controller , death-sequence => use physics controlled rag-doll simulation) ? Why do you need friction (to avoid that entities slip down a slope ? ) ?

 

There's no general good way of handling it, I would sugguest to think about all (most) of your requirements, then try to think about a solution. I started with a dynamic controller in my game (steered by forces) and after years of frustration (dynamics are really hard to get under control ), I switched to a much easier kinematic controller..

Edited by Ashaman73

Share this post


Link to post
Share on other sites
haegarr    7372


Does this make it difficult to program the AI? I haven't programmed AI before,

I'd make a distinction here in order to not clutter sub-systems: AI is about decision making under consideration of the known world state. Output of AI may be "go to X". If you actually want to use dynamic motion, then force may be the output of the locomotion system but not of the AI. Under this view, using force does not make AI itself more difficult, because AI itself is independent of that.

Share this post


Link to post
Share on other sites
Cacks    179

Hi haegarr,

 

I would like the AI to decide what it wanted to do then send events containing the forces to achieve it's goals

 

Is this not a good idea?

Share this post


Link to post
Share on other sites
haegarr    7372
I would like the AI to decide what it wanted to do then send events containing the forces to achieve it's goals
 
Is this not a good idea?

If you actually mean physical force then it is not a good idea. Notice the overall complexity of a game. The human approach, especially but not only in software engineering, is to modularize a problem into smaller ones until the parts become (more or less) easy to manage. Further, coupling the parts only when and where meaningful keeps the maintainability of the whole construct.

 

One of the higher levels in this modularization process is often named "sub-systems". Input processing, graphics rendering, sound rendering, physics simulation, AI, networking, ... are such sub-systems. Each one has its task. You should not mix them up. It is okay if some sub-systems use the output of other sub-systems to fulfill their own task (this is the said coupling), but each sub-system has its own responsibilities.

 

Creating physical force is not the responsibility of AI. Instead, AI uses sensors to investigate the environment, checks the needs of the driven agent, makes decisions and finds goals perhaps considering knowledge and emotions and culture, makes plans to reach the goals, and steers the agent accordingly by executing belonging actions. This is already a sufficiently complex problem by itself. (Not each AI considers all enumerated topics, but I wanted to show margins in which AI works.)

 

Actions output by AI are still somewhat high level. Sub-systems at lower levels deal with them. E.g. actions belonging to movement of the agent may be processed by the locomotion sub-system. This again may drive the animation or physics or both sub-systems. In your case of dynamic motion, the locomotion sub-system may output some physical force as input to the physical simulation.

 

 

EDIT: BTW, I'm seconding Ashaman73 suggestion to switch over to kinematic control.

Edited by haegarr

Share this post


Link to post
Share on other sites
haegarr    7372


can I still model friction using kinematic control?

Oops, I missed your post mentioning ice hockey...

 

Well, when using kinematic control you would go with animations that look like as they consider friction. This is of course different from motion by calculating effective friction at each simulation step. However, in your use case you have an ever horizontal plane with the same friction coefficients everywhere. If you not directly allow the player to control the position of the skates' runners, I would say (just my 2 cents!) that it is relatively easy to use good looking kinematic control here.

 

In the end it is a question of what your goals are w.r.t. the simulation aspect of the game. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this