About Store Forum Documentation Contact



Post Reply 
Obstruction & Collision Questions
Author Message
Chris Offline
Member

Post: #1
Obstruction & Collision Questions
Hi,

1. With the current ball-based camera collision the camera makes sure the player is always visible:

Code:
desired_camera.setSpherical(Players[0].pos(), desired_camera.yaw, desired_camera.pitch, 0, desired_camera.dist);
        
Ball ball(0.1f, desired_camera.at);
Physics.move(ball, desired_camera.matrix.pos-ball.pos);
Cam.setPosDir(ball.pos, desired_camera.matrix.z, desired_camera.matrix.y);

However in an awful lot of third person games it allows the character to be obstructed by pillars, mountain peaks etc. This is the character collision behaviour I want. I thought that a way to do it would be to check if the y axis of the camera matrix pos collides with anything and set it to that, using a ray phys_hit but have been unsuccessful in my attempt. Could someone assist?

2. Similar to the cloth tutorial, i'm using a kinetic helper ragdoll on my character (for a custom bone-control grabber-like interaction system), my question is; how can I disabled the default bounding cylinder for collision with everything (e.g. barrels) other than the terrain? I've tried with collision groups to no success here.

3. Is there any preferred way of making a bounding sphere/box (e.g. using the viewport range) for ray-testing? (say I want the character to move in the direction of the sky)

Thanks.
12-15-2009 05:40 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Obstruction & Collision Questions
1. in Physics.move you can specify only certain actor groups

2. Physics.ignore

3. I don't quite understand
12-15-2009 05:44 PM
Find all posts by this user Quote this message in a reply
Chris Offline
Member

Post: #3
RE: Obstruction & Collision Questions
Hi Esenthel,

Thanks for your quick response. In:

1. I don't want to specify actor groups: take the example where your character is in a valley, if you rotate the current third person collision camera around the valley (zoomed out at quite a distance), the camera will jump forward infront of any terrain obstructing the character. However, I don't want it to do this, only to preserve the collision on the y-axis.

2. I'll play/debug more with this then, I probably just set it wrong before.

3. E.g. when you have something like:

Code:
if (view==VIEW_ISO && Ms.b(0)) {
    Vec     pos,dir ;
    ScreenToPosDir(Ms.pos,pos,dir);
    PhysHit phys_hit; pos-=Vec(0,0.7,0);
    Bool temp=Players[0].ctrl.actor.ray(); Players[0].ctrl.actor.ray(false);
    if (Physics.ray(pos,dir*ViewportActive.range,&phys_hit))
        Players[0].actionMoveDir(phys_hit.plane.p-Players[0].pos());
    Players[0].ctrl.actor.ray(temp);
}

And the player clicks the sky, they wont move. If this behaviour is undesired, you need something bounding so that the ray collides with "the sky", I was wondering if theirs a preferred way to do this.
12-15-2009 05:54 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Obstruction & Collision Questions
1. yes and you need actor groups for that
you can specify only IndexToFlag(AG_TERRAIN) as 'group' parameter in move function, this will detect collisions only with the terrain

3. maybe you can just use 'dir' from ScreenToPosDir then there is no physical collision?
12-15-2009 06:48 PM
Find all posts by this user Quote this message in a reply
Chris Offline
Member

Post: #5
RE: Obstruction & Collision Questions
With 1. Thanks again for your response, I tried with actor groups but this just seems to enable or disable collision for an entire group. After studying the problem more, I eventually got it to mostly work as expected with the following behaviour from an additional Physics move (the first one starts at the camera and moves towards the character, the second one moves back normally, to pinpoint an obstruction. This mostly works with the odd clipping glitch which I can't get my head around.

Please try the following collision code on hilly terrain to see what I meant:

Code:
Ball ball(0.1f, desired_camera.matrix.pos);
Physics.move(ball, desired_camera.at-desired_camera.matrix.pos);
Physics.move(ball, desired_camera.matrix.pos-ball.pos);
Cam.setPosDir(ball.pos, desired_camera.matrix.z, desired_camera.matrix.y);

I think this is pretty much there now, but may not be the best way to do it.[/code]

Oh and thanks for your suggestion in 3.
I'm much more happy now,
Chris
12-16-2009 12:16 AM
Find all posts by this user Quote this message in a reply
Post Reply