How do I make my character walk? -
05-14-2011, 05:51 PM
I want to make code when I press up/forward, down/backward, etc. I want my character to walk while I move my character. What kind of code do I make for this to happen?
Go to the events, and find the "When a key is pressed" event. Right-Click it, and say change to "While a key is pressed" Then make a method that says move forward (the speed you want it to go), and put it inside the "during" part of the while a key is pressed thing. Repeat this for turning and moving backward as well.
For walking, if your character is made in the people creator, you can use the inborn walk method, messing with the time parameter that shows up when you put it in until it matches the walking time. Put this in a do together block with the movement, and voila, the guy walks and moves at the same time when you press the appropriate key.
--------------------------------------------------------------------------------------------------------------------------
I have plenty of common sense. I just choose to ignore it.
-Calvin and Hobbes
Wondering about my Avatar?
http://en.wikipedia.org/wiki/Tardigrade
Wondering about my username?
http://www.youtube.com/watch?v=jG7vhMMXagQ
Then you would need to make your own walk method by, probably by either setting poses and saying set pose back and forth in a realisic way, or just moving the subparts, and then put it in the method in the same way.
--------------------------------------------------------------------------------------------------------------------------
I have plenty of common sense. I just choose to ignore it.
-Calvin and Hobbes
Wondering about my Avatar?
http://en.wikipedia.org/wiki/Tardigrade
Wondering about my username?
http://www.youtube.com/watch?v=jG7vhMMXagQ
You want to know how to make an NPC walk? I'll assume you made a walk animation. First things first: The thing you're trying to make is called an AI. Problem is, I don't know what you want to do with it. Well, what do you want to do with it?
Let's assume all you want to do is get the foo to walk in a random direction at random times.
Make three random numbers. One is between 0 and 10, the second is between -.5 and .5, and the third is between 0 and 20. The first one is how long a wait should be done between walks. -.5 and .5 denote which direction it should walk in and by how many degrees, up to 180 degrees left and 180 degrees right. 0 to 20 is how many meters it should walk.
Make an event that executes this method, and by that I mean every 0-10 seconds it makes an NPC turn -180 to 180 degrees and complete the walk animation while moving forward 0-20 meters.
If you want the NPC to chase the camera, you simply have to do the same thing, except make the NPC face the camera.
This is kinda cheap. At some point someone will figure out how to get the NPC to follow a path in order to reach you.