I’ve searched through the old posts for helpful explanation, but didn’t see anything.
I am working on a small, 1st person game and was trying to get the player movement working. I am attempting to use the player.py script from the Squash the Bunny game in the Blender Gamekit, but for some reason I am not getting any movement. So far the mouse is working with the script and I have the rotating of the player working.
The player is an empty and is the parent of the camera. I have made the empty (Player) an Actor and Dynamic. I think the problem is that my collision sensor for ‘touchfloor’ (like in the example) is never being fired - I am not sure what should be firing it either. I have made a property for the room of ‘floor’ and set it to 0.0 (like in the example), but still nothing.
If anyone has used the script from that game or knows another method that is easy for player movment, I would appreciate it. I want to use the W,S,A,D keys for forward, back, left and right, respectively.
I initially started just using the keys without a python script and changing the dloc, but the problem I ran into is that I have stairs that I need to be able to go up.
Any help would be appreciated. Thanks.
Well, why are you using a script for player movement? Why not just use hte normal motion acuator? It’s easy to use, and doesn’t really ever get problems.
I started off using the motion actuator, but ran into a problem when trying to go up stairs. Is there a way to use the normal actuator and handle going up and down stairs?
I suppose that if you made the stairs seperate objects and gave it a material called “stairs” it would work. Just make a touch sensor and make it so that it always adds a little upwards force when you’re touching the stairs.
Not sure how that would allow going down the stairs though. And even if it did, wouldn’t it be a little jerky with slight upward force and then falling down to the next step?
Why don’t you make a jump movement for going up stairs?
Well I was trying to get a natural movement when moving though a room. So if you had the ‘W’ key pressed you would be moving forward and if you came to the stairs you would continue moving forward and just walk up the stairs. Same thing for going down them. Seems like if you had to jump each time you wanted to go up a step or down it would break away from the natural forward movement.
I found a way that works pretty good for stairs using Blender’s dynamic material settings. Check out the FH settings for dynamic materials.
You happen to know of a tutorial on how to use the different Fh settings of the materials would you?
OK, I’ll try yo give a step-by-step discription.
First give your stairs a material. Now look in the material buttons, look to the left of the colour sliders, and click the button marked ‘Dyn’. Several new buttons and sliders appear, I’ll briefly discribe what they do.
- “Friction” The amount of friction applied to objects sliding over the surface.
- “Restitute” is how bouncy the material is.
- “Fh Force” controls the amount of force is applied to keep an object above the floor.
- “Fh Dist” is the distance outward from the face that Fh force affects.
- “Fh Damp” dampens the Fh Force so that you don’t have objects bouncing at the edge of Fh Dist.
- “Fh Norm” applies a force in the dirrection of the slope, so objects will slide down hill when Fh settings are used.
For the stairs, make Fh Dist equal to the height of one step. Set Fh Force to 1. Experiment a little with Fh Damp, I find a value of 0.2, or 0.3 works well.
Give your floors, and other surfaces that can be walked on, the same material as the stairs.
Now select your dynamic character, and look at it’s collision sphere. The bottom of the sphere should be the same height above the ground as the Fh Dist in the ground material. In the dynamic settings for the character, click the “Do Fh” button, this makes the character respond to the Fh settings of materials.
Try it, it works especialy nice on stairs.
why go through all that garbage? just make a transparent ramp over the steps - you will still have the illusion of walking up steps. alot of major games use this technique.
I’ve seen people use the transparent ramp solution, I think it sucks. Because when the character stops moving, it begins to slide down the ramp. This is unrealistic, and makes the game seem unprofessional.
oooh! oooh! I know the answer to this one! I’ve done it in a first-person game I made, and its works so beautifully. You make it so the character goes up stairs (using alot of upward force) when touching them AND you’re pressing your forward key. This makes a very beautiful “stepping” effect when going up and down the stairs. It really works! [!]
tmtechie, plantperson: Thanks for the comments - I’ll keep that in mind for future work.
wiseman303: Thanks for the tut on how to set it up. Followed your steps and now it works The only thing I have left now is possibly looking at changing the size of the stairs. Some of the them might be a little large because it takes the viewer a little bit too long to get up the steps. Is there a way to speed that up without changing sizes around?
That method might be ok for 1st person games if your not going to bother animating the character with armatures. Its a similar method to what was used in the original egypt.blend example file, although that took ages to walk up steps (probably not enough Fh Force). But if you’re planning to animate the character wih armatures then you’ll have to make an animation of the character walking up steps anyway, so it would be much better to do the actual movement with an IPO rather than Fh Force.