Advertisement

idea for character control system

Started by August 07, 2007 04:03 PM
2 comments, last by speciesUnknown 17 years, 3 months ago
Hi, I'm currently building a new character control system, in which the movement of each character is abstracted from the character itself. The language is c++. I've designed the basic structure on paper and written the class headers. I;d like to hear some opinions from people with experience of this kind of stuff. Heres how it works: The game engine has a vector of characters, each owning a mesh and an inventory. It also has one vector of human players, and one of AI players. The idea is that each character is "controlled" by one of these entities. When a character is spawned, Either an AI player is created, or the character is put under the control of a human player. Either way, the class that controls the player has a pointer to the character and that is used to manipulate the character's properties, including which direction and speed its moving at. The AI and human player objects both set the movement vector, animation state, and the selection of weapons. The character object controls health, life and death, and calls the renderer and collision detection systems. (as yet they all run around on a plane because collision is not finished. I'm working on it.) When a character is killed, a flag in the object properties is set and the player (AI or human) which controls that character is notified about the death. later in the same time frame, the character is deleted and the memory is recycled. If the character was controlled by an AI player the same happens to the AI player entity. It is removed and the memory is recycled. Theoretically, I should be able to implement a system where any character can be controlled by the human player, and any character can be put under the control of an AI player. Has anybody tried something like this before? What are the pitfalls of this method, do you think? Does anybody currently use a similar method?
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
Quote: Original post by speciesUnknown

Has anybody tried something like this before? What are the pitfalls of this method, do you think?

Does anybody currently use a similar method?


Just about any sport game out there. In FPS's, there was that game Messiah where you could control any agent in the game, literally by jumping in their body.
Advertisement
All you're doing here is separating functionality into two coupled classes ('controller' + 'vehicle'). That's not new... it's just a reasonable thing to do. You could also consider the problem from the perspective of the vehicle owning an instance of a controller (in this case, a character body owns an instance of a controller, be it a keyboard/mouse/gamepad/joystick interface, or an AI class). Do what you think it right for your game and your code design.

Cheers,

Timkin
Thanks for the support.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!

This topic is closed to new replies.

Advertisement