Cannot walk INSIDE buildings.

I have been trying my hardest to research this for quite some time. But most of the topics are based upon something totally different.

I’m trying to make it so that when I import a building, I’m able to walk inside the building, but not through the walls.

I’m using the Roaming Ralph collision detection,
And it works great. However, If I place a wall,
I’m able to walk through it. I fixed this, Sort of. But now when I walk into a wall, I automatically appear on top of this wall.
By wall - I mean a building in specific.

By this, I cannot walk inside a building, But rather appear on top of it, If not, then through the wall.

I’m however, Not going to lie. Collision confuses me. So if all possible, I’d like a good explination.

If I recall correctly, Roaming Ralph does this by checking the name of the first collision on the part of the terrain ray, and, if said collision is not with the terrain, resetting the character’s position.

[edit]
For a brief description of what I believe is happening, take a look at my last post in this thread.
[/edit]

On the other hand, I suspect that I’d more likely have two collision techniques:

  1. Terrain height
    The Roaming Ralph system, used only for setting the character’s z-coordinate (and possibly replaced by another system depending on my circumstances - I seem to recall that GeoMipTerrain could simply fetch the z-coordinate for a given x and y, for example).

  2. Obstacles
    A collision sphere attached to the character and controlled by a CollisionHandlerPusher, set to collide only with non-terrain obstacles.

The various types of collision object - terrain, obstacle and any others that you might have - are then distinguished using bitmasks (for which see this manual page).

I tried this,
And by the looks of it, It MIGHT work (Haven’t been able to test it, I’ll tell you why).
It seems i’m able to walk UP my mountains, But not back down. I’m just making a guess it’s because of my collision sphere getting in the way?

Anyways, Would you happen to know how to fix this?
Or even test to make sure it is my collision sphere by making it visible?

I haven’t been able to test the “Walking into a building” thing, since my house is at the near bottom of the terrain.
So would you happen to know how to fix this?

EDIT: I fixed it. It’s “cicle” was too big.
However, Using this:

Cnode.addSolid(CollisionSphere(0.04,0.04,0.02,0.02))

I can walk up and down hills with ease. However, I still warp to the top of buildings. But i’m then not able to walk off the roof anymore. Which is fine, But i’m more interested in not appearing on the roof;)

I realize the (0.04,0.04,0.02,0.02) must be off, and this will (Most likely, if i’m not mistaken) fix my problem, But i’ve done a lot of Trial with this, And I cannot seem to figure which to use for both, Walking up hills, Walking down hills, Not walking through walls, and not appearing on top of walls when colliding with them. With this, I’m sure it’ll allow me to walk below a roof? If not, I’ll possibly need help with that too.

As the collision ray comes from thy sky and looks for the first intersection, you need different bitmasks for the collision. Look at this panda3d.org/manual/index.php … n_Bitmasks
which should be easy. Use different bitmasks for the floor and buildings. Then the collision ray ignores the roof and intersects with the floor.

Heh, you seem to have missed what I said about bitmasks - the size of your sphere is very unlikely to be the real problem. Using bitmasks to distinguish between “terrain” and “things I shouldn’t be able to walk through” should solve your problem, and allow you to increase the size of your sphere, if you so desire.

Ah, I did look through and add this last night, but I must not have gotten the right one put in. I’ll definitely be add this stuff, thanks:)

I’ve tried many different ways of using bitmasks, but I can’t seem to figure out which one will help me. Some make it so I can’t walk, some make it so I can’t go down, some make it so I can’t change my Z by terrain, and none enables me to walk under my roof of the building.

Any ideas asto what kind of bitmask for walking under areas as well as over?

Don’t forget to apply the bitmasks to the terrain and obstacles as well.

(By the way, unless you’re comfortable working in hexadecimal, I suggest using the “.bit” syntax used in the example at the very end of the page linked-to above. It should allow you to clearly set specific bits rather than working out what the hex representation of said bits is, I believe.)

The idea, essentially, is to use masks that don’t “overlap”:

(I’m presuming here that your sphere and ray are “from” objects, and that your terrain and obstacles are only “into” objects.)

For example, give your terrain an “into” mask of “bit(1)”, and your ray a “from” mask of “bit(1)” - this means that the ray should collide with the terrain. Then assign to your obstacles an “into” mask of “bit(2)”, and your “obstacle collider” (your sphere) a “from” mask of “bit(2)”.

This means that, in binary, the masks should look something like this:

    Object     |  Mask
-------------------------
 terrain       |  0001
 terrain ray   |  0001
-------------------------
 obstacles     |  0010
 sphere        |  0010

Note that the two sets of binary representations don’t overlap - they each only have "1"s in a location in which the other doesn’t. Thus your ray should collide with terrain but not obstacles, and your sphere should collide with obstacles but not terrain.

So if I was going to add these bits to an obstacle, and my character bit was 0, that means I’d only be actually walking on the objects or terrain, or whatever it is, of 0?

And how would I go about adding this to the actual object I’d be waking on?
I’m guessing just like that collision code in the very bottom, they made the box act as if the terrain from using bits? Which means he’d be walking ON the box?

Just trying to clarify it up, a bit.
So how would I add this to only the bottom area for “walk-over” of a house’s floor, make the walls block me, and make the roof so I’m able to walk on them, but only if I’m intentionally trying to (if I were to jump on it)?

I’m not sure that I understand you correctly, but if so, then yes, that seems more or less accurate.

(The phrase “the objects or terrain, or whatever it is, of 0” doesn’t make much sense to me; if you mean “the objects or terrain, or whatever it is, that have an into bitmask of 0”, then yes.)

As to the example, I don’t know - despite the model name - that that’s intended to be applied to the Roaming Ralph sample itself; for one thing, I think that the mask should be applied to the collider, not the Ralph model. I suspect that the name “Ralph” is just being used there as an arbitrary example.

As to separating the floor, ceiling and walls, I imagine that the easiest way might be as follows:

When modelling, name the wall collision geometry something along the lines of “walls”, and the floor and ceiling something along the lines of “floor” and “ceiling” respectively - something easy to search for, at least.

When you load the model, you then search for each of those and set their “into” masks appropriately.

(If you’re not sure of how to search for parts of a model, look here (after the section on nodePath.ls, I believe).)

There might be a way of setting the masks directly while modelling, but if so then I fear that I don’t know how to do it, I’m afraid.