I’ve been trying to think of different ways that you could set up a FPS so that the character can crouch. All of my ideas have had flaws. Basically, I want to make the player be able to crouch and the player’s bounding box needs to get shorter as well.
I figured I might as well ask here, because I know somebody must have a good idea for how to do this. All help is appreciated
Perhaps having 2 bounding boxes instead of 1. Top one is parented to the bottom one. When the character crouched, the top box moves or rotates into a lower position
Parenting wouldn’t work, because the child object won’t have collision.
That might work. I probably could replace the bounding box mesh with a shorter one. Then I could just have an IPO for the camera to move down. That might just work!
Parenting wouldn’t work, because the child object won’t have collision.
It would if you enable ‘Compound’ on the father object and ‘Add to parent’ to the child object (which has dynamic enabled).
In 2.5 in both cases it be called Compound, I believe.
Interesting, since I’m also working on that I did consider scaling down or the solution mentioned with the smaller box on top which will be moved down as well. I’ll give it a try too.
I tried sago’s suggestion with “Compound” (main lower box) and “addParent” (upper box) and it works flawlessly. I still wonder if the scaling-IPO would be more “secure” in matters of physics/collision issues… because it wouldn’t need to be added into the “compound” I guess… any ideas which is better?
edit: hmm I’m not sure for the above solution, with the upper box moving downwards: the IPO doesn’t seem to update the collision… and therefore still cannot crouch
Also, supendDynamics() does not work, downscaling does not work… hmmm and reinstancePhysicsMesh() will also not work because the API says it does not work on compounds…
Has anyone actually solved this seemingly easy - yet difficult problem?
edit2: ok, as long as one does not use a compound object (of 2 dynamic boxes), and instead uses a single one… the crouching works via “downscaling” - IPO. But let’s say you put in this “box” a playermodel: wouldn’t it be downscaled as well when parented to the “box”?
Interesting… the replace mesh actuator replaces the physics mesh, but rigid bodyies still does not recognise is… more confusing this does not work for dynamic objects… This is not good.
It works with addObject and endObject. But that makes it much more complicated. Especially you have to reparent the children and add all logic bricks on both objects (<ctrl><c> would help with that).
I can’t recomment that.
I was looking into this a few months ago. I tried every method suggested here except the compound objects. I found replace mesh worked, as long as your character is a single object, but it requires you to use triangle mesh which didn’t work with my setup. I then tried IPO’s but I found being forced to use logic bricks restricting. I finally settled on using python and object.localScale for basic crouching. Scaling the children up while the parent scaled down. It appeared to work, although it seemed like a fair amount of code for something that sounds so simple…
Hmm I see an error in that, I experienced as well: if you place a static box in the height of the upper box to simulate a “tunnel” which forces you to “crouch” under - although the playermodel is standing it will pass through. It seems there is no collision anymore on the upper box, although I can see it is “Dynamic”…
I resign and probably do the scaling trick (see attachment), which was mentioned by gomer:
somehow the scaling down process is slower during scaling action, than the upscaling and therefore make an “egg-shape” meanwhile… any solutions to that?
(hold C to downscale during playmode)