User & AI character movement Plumbing

Started by
9 comments, last by Cacks 9 years, 3 months ago

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

Reject the basic asumption of civialisation especially the importance of material possessions
Advertisement

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.

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

Reject the basic asumption of civialisation especially the importance of material possessions

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..


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.

Hi Ashaman73,

it's an ice hockey type game so I need to simulate friction on ice,

How do professional companies do it?

cheers

Reject the basic asumption of civialisation especially the importance of material possessions

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?

Reject the basic asumption of civialisation especially the importance of material possessions
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.

Hi haegarr,

cheers for the advise

can I still model friction using kinematic control?

Reject the basic asumption of civialisation especially the importance of material possessions


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.

This topic is closed to new replies.

Advertisement