3rd person camera collision

Software: Away3D 4.x

kurono, Sr. Member
Posted: 03 March 2012 09:00 AM   Total Posts: 103


I want to implement colliding 3rd person camera for character. I tried to do it basing on HoverDragController class and AwayPhysics. HoverDragController has three main properties: target (i.e. my character’s body), orbit radius and camera position itself.
The scene has a cube (character) and some boxes of AWPRigidBody type.
To perform camera’s collision I cast a sphere from my character’s position to the desired camera position. If a sphere hits some body I move camera to its position.

= new Mesh(new SphereGeometry(25), mtl);
c.castsShadows true;
_camBody = new AWPRigidBody(new AWPSphereShape(25), _camObject0.001);
_camBody.gravity = new Vector3D();
_camBody.position = new Vector3D(100300100);


private function 
onCameraCollide(e:AWPCollisionEvent):void {
.radius _r .9;
trace('collide at ' _r);


/* on enter frame */
// throw a ray from target to camera
var direction:Vector3D = (_camController.pos).subtract(_camController.target);
_camBody.position = (_camController.target).add(direction);
_camBody.gravity = new Vector3D();
_r += 10;
   if (
_r >= _camController.radiusBounds[1]{

It works but a little bit not like I wanted. Assume that large cube is between character and camera. I threw a sphere from camera’s target (i.e. character’s actual position). Sphere collides one of cube’s walls and calls “onCameraCollide”. Camera moves to sphere’s position. Everything is fine. But if a sphere is inside a cube it still calls “onCameraCollide”!!! And my camera occurs inside the walls. Please help me to fix it!


kurono, Sr. Member
Posted: 03 March 2012 09:27 AM   Total Posts: 103   [ # 1 ]

Probably I should to set constant velocity (10) for this sphere instead of force movement according to direction. In this case, once collide with wall, sphere can’t occur inside it.



Away3D Forum

Member Login