• Advertisement

# Moving inside an object

This topic is 1960 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Hello guys,
I'd like to know how to make a character moving on or inside other objects.
E.g. If I got the model of a house and I want the character to be able to walk on the roof as well as inside the rooms.

For moving on top of it, I suppose you need to find the triangle the charactermodel is touching, then get the height of the point inside the triangle.
But how can you get the triangle and how can you do it fast enough in big models?

To move inside of a model . . . I have no idea what to do. Could you give me some tips?
(I'm using directx 11 and c++)

Thanks a lot Edited by gnomgrol

#### Share this post

##### Share on other sites
Advertisement
I dont understand what you mean by moving on or inside other objects, like you want to test for collison ?

#### Share this post

##### Share on other sites
Well it is a question collision detection in general, which is rather huge subject and there isn't simple solutions to it.

For example, you could consider your player to cast a vector from it's position downwards and check which triangle is being hit and if it is close enough, get the position from the vector/triangle hit test otherwise the player is falling. For the walls, you can consider the player to be presented by a sphere for example and then scan nearby triangles and move the sphere outside of the triangle plane if there is intersection. This is rather crude and will fail eventually at some cases.

You could look into some existing physics libraries such as ODE and Bullet which will do the collision detection for you. I think that Bullet may even support hit detection with fully polygonal models. This will save you a lot of head ache.

Cheers!

#### Share this post

##### Share on other sites

I'd like to know how to make a character moving on or inside other objects.
Let's start from the basics. By default, nothing prevents two simulated objects from fully encroaching each other. This is ideal for ghosts and not so ideal for pretty much everything else.
There's no such thing as "moving on or inside". We want to move it on. Or in. Those are two very different things.
So as others have pointed out, you need some sort of collision detection (library) to first prevent encroaching, then find a way to let it happen selectively... or perhaps not? Let me elaborate.
E.g. If I got the model of a house and I want the character to be able to walk on the roof as well as inside the rooms.
Nobody, nobody serious would model a whole house using a single collision shape (physics model). In general, most maps are made of collections of independent convex hulls. This implies there's no such thing as "in the room" but rather "not in something solid".

To be more explicit, you don't move inside of a model but rather
build your model in such a way it has empty space inside
OR
find a way to make the model non-solid selectively.

For moving on top of it, I suppose you need to find the triangle the charactermodel is touching, then get the height of the point inside the triangle.
But how can you get the triangle and how can you do it fast enough in big models?
In line of principle, what you're trying to do is "contact point generation". I have experienced quite some pain with it and I therefore strongly suggest the use of a library.

What other people have not written is that you're going to take a stroll in the beautifully complicated world of kinematic objects (stuff that moves). This is going to require some hair pulling. Edited by Krohm

#### Share this post

##### Share on other sites
Hi there.
If it was me and it was my first time at doing this(which it would be) I would use some flat planes layed out on your floor and roof and anywhere else you want to walk on and export them as walkways.meshes keep there wold pos based on the models its for, that way you can use the models world pos to locate it. Make them one sided meshes, also this way you can render just the walkables to test your would when setting up.

#### Share this post

##### Share on other sites
This would be very limited, and making it work fast still requires some effort. If this is how you would do it, then just use a physics library.

#### Share this post

##### Share on other sites
Thanks for all your answers, I will look into a lib.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement
• ### Popular Tags

• Advertisement
• ### Popular Now

• 11
• 11
• 9
• 12
• 10
• Advertisement