I'm new to programming video games. So I would like to know how to integrate the control of modeled characters in the source code? Thank you.
I'm new to programming video games. So I would like to know how to integrate the control of modeled characters in the source code? Thank you
You have to be more specific, what do you mean by “integrate control of modeled characters in the source code?”. Do you want to load the model or Do you want to control that character model?
Nestor2409 said:
@undefined Control the movement of the character in the source code.
So, what do expect from people here? To write the code for you? To show you some random code that you can copy? Not gonna happen.
If you have specific questions or are stuck with certain aspects of what you want to achieve, then ask a more specific question.
Even if you are just looking for ideas, be more specific: What kind of movement do you want, in what kind of game? What tools/languages are you using? What integration do you already have for your character?
And, most importantly, look at your own post. Read it. Think about what anyone could answer. Then you'll see you have to ask better questions.
In the program you have several relevant variables, like x,y position, or x, y, z position if you are in 3D. Other possible variables are the direction the character is looking, what he is holding in his hands, what cloths he is wearing, basically anything that can change during the game. (That is, if he is for example always wearing green cloths, there is no point in having a ‘clothes’ variable, since it won't ever change.)
The standard pattern for control is a game loop, basically a ‘forever do’ loop, where you
- read user input (keyboard, mouse, or joystick) so you know what the user wants the character to do
- compute whether what the user wants is actually possible and not fatal. (That is, running into a wall should not be possible in general, and running into a fire is often a fast way to die, resulting in “game over".)
- If all is fine, update the relevant variables, eg the position so the character is actually moving.
- Finally, draw the character using its (updated) variables so the screen displays the resul of the user action.
- And that's it, please loop back to the first point.
You exit the loop when the character dies or has won the game.
In reality, there are more bullit points in the loop, eg enemies need to move around as well using their own set of variables, timers may expire, remaining energy may decrease over time, etc etc. Each thing that needs repeatedly a small update is part of the loop so it gets visited and has the opportunity to update itself.