Make the camera collide with objects

Hello! I’m testing chaseCam and i want to prevent it from going through others objects.

For example, here Oto got the cam on his back,everything is normal

https://picasaweb.google.com/lh/photo/mFdm-badXXa1g2rAEvBHueIzLtO65Y37MbmRbzz0LYY?feat=directlink

and then,i rotate a bit the cam and it goes through a building and the floor.

https://picasaweb.google.com/lh/photo/STKO6kfyLgFZu70OSKq9_-IzLtO65Y37MbmRbzz0LYY?feat=directlink

How can i prevent this?

Is there something i can use,or should i implement it?

Its outlined in the collision tutorial.

Please forgive my blindness,but… i can’t find anything about it…

“9. Hello Collision”

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3#tutorials_for_beginners

I didn’t mean the article,i mean the point where it says something about that. I can only see about the first- person camera…(You really must hate me!!)

Shoot a ray from the character your looking at to the camera.

Get closestCollision. If the distance is lower than the distance between your character and camera

then set the cameras location to be your characters position + the direction of your ray times (the distance to first collision - 1)

2 Likes

thanks for the tip,ill do it right now :))

j0hnskot said:
I didn't mean the article,i mean the point where it says something about that. I can only see about the first- person camera..

oO The whole tutorial is about linking the camera to a character so it moves along with it...