Camera which detect objects

Hi, guys,

This is my first post. Greetings to community. :smiley:



I'm trying to do a camera to follow an avatar. So, I mean, if avatar is inside a room, the camera automatically changes its position. My camera follows avatar, but how can I do to detect avatar to change camera's position?.



I'm spanish, sorry for my english.

It sounds like you're already able to follow the avatar with your camera, but I don't understand the second part of your question.  Are you trying to detect a second avatar to change the camera or detect change in the first avatar, or something totally different?

Thanks for reply, sbook.



Yes, you are rigth. My explanation is very incoherent. I'm sorry.



I'm going to try explain it again.



I need a camera which can be detec collisions for intelligent translation. I mean, imagine a very narrow hall or an upstairs. I need that the camera positioned itself automatically to see avatar and don't miss him.



I hope my explanation is useful, this time.

Hi!



I think there is nothing like this built in jme2, but I have some hits that could help you.



In order to avoid passing through walls, you should test collisions between the cameranode and your scene (walls, floor, roof and so on) and replace the camera depending on the normals of the wall collided.



Also,  you would like to avoid loosing your player because there is a wall between the camera and the player. You can cast a ray from your camera to your player's position and check collisions between the ray and the scene and chage the position and lookat of the camera.



Hope thiks helps a little.



PS: I'm also spanish, if you need further clarify (in spanish) just PM  me.

Thansk for your help, joliver82.

I'll try to test with collisions because in my enviroment I don't know whether avatars response to ray query or not. I think yes: avatars has a bounding Volume.



Collisions at node camera are the same as in normal nodes?.






I have never needed to test camera collisions, but I think that it should work in the same way, as cameranodes are also nodes :wink: I would try to asign a boundijng box manually to the camera using as its dimensions the distance you would like to be away from walls. Also this distance should not exceed the width of the narrowest corridor in your game.



If you get it done, just tell :stuck_out_tongue:



good luck

I'm going to try it and advice you :D.

Thank for help.

That doesn't work. My camera always pass trough walls.

Could someone explain or provide some pseudocode on how to move the CameraNode based on the normals of the wall of that was collided with?


joliver82 said:

Hi!

I think there is nothing like this built in jme2, but I have some hits that could help you.

In order to avoid passing through walls, you should test collisions between the cameranode and your scene (walls, floor, roof and so on) and replace the camera depending on the normals of the wall collided.

Also,  you would like to avoid loosing your player because there is a wall between the camera and the player. You can cast a ray from your camera to your player's position and check collisions between the ray and the scene and chage the position and lookat of the camera.

Hope thiks helps a little.

PS: I'm also spanish, if you need further clarify (in spanish) just PM  me.

Do you have camera collisions?. If you have this, I can help you with that. I only need code to provide collisions to cameraNode, I can't do it.