Keep my model in the environment

Hi!



I have a model inside a room. The room is just 4 walls and a floor that are rectangular boxes. I've detected when my model (ch) is near a wall. For example:



if ((ch.getWorldBound().intersects(wallX.getWorldBound()))



And my problem is that I don't know how can I do to keep the model inside the room. I think I can do something like return to the previews state when the model intersects with a wall or something like that.


yes u can do that.



or u can just make a final variable of the minimum distance between the character and the wall.



and when the player's position is getting closer and closer to the wall, u just stop moving the character.

You store the previous position in a variable, then apply a new position, check if the player intersects, if he does, use the previous position, otherwise keep the new position.

Momoko_Fan said:

You store the previous position in a variable, then apply a new position, check if the player intersects, if he does, use the previous position, otherwise keep the new position.


I've been trying this, taking 'WorldTranslation'. The problem is that there isn't a 'set' method (setWorldTranslation(Vector3f)). How can I change the position?

Excuse me, but it is my first real program.

I believe your going to want to be using the local translations. 8)



Have you worked through the tutorials? They would get you off to a great start.

nymon said:

I believe your going to want to be using the local translations. 8)

Have you worked through the tutorials? They would get you off to a great start.


Sorry, as soon as I've answered I've realized that  I made a stupid question. It's running perfect know.
The tutorials are really useful. I won't know what to do without them.

Thank you!!!