|
c_trace for camera collision problem (SOLVED)
#385093
10/12/11 20:02
10/12/11 20:02
|
Joined: Sep 2009
Posts: 84
Theil
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2009
Posts: 84
|
I've got this piece of code for the camera on a third person view
if(c_trace(my.x,camera.x,IGNORE_ME | IGNORE_PASSENTS | IGNORE_MAPS | IGNORE_PASSABLE | IGNORE_SPRITES | IGNORE_CONTENT) > 0)
{
vec_set(camera.x,target);
vec_add(camera.x,normal);
}
else
{
camera.x = me.x - camera_distance * cos(me.pan);
camera.y = me.y - camera_distance * sin(me.pan);
camera.z = me.z + camera_distance;
camera.tilt = -(camera_distance/3);
camera.pan = me.pan;
}
But when I test it and I put the player in front of a wall I get a flickering effect, it's like the camera is going forward and backward like if it is executing the if statement and right after that it runs the else statement, what do you think is the problem here? Here is a gif that illustrates my problem:
Last edited by Theil; 10/14/11 13:32.
|
|
|
Re: c_trace for camera collision problem
[Re: MrGuest]
#385102
10/13/11 00:22
10/13/11 00:22
|
Joined: Sep 2009
Posts: 84
Theil
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2009
Posts: 84
|
Hahaha I thought the same about the epilepsy warning, let me try that, I guess I will later remove this picture. Edit: just tried this out
if(c_trace(my.x,camera.x,IGNORE_ME | IGNORE_PASSENTS | IGNORE_MAPS | IGNORE_PASSABLE | IGNORE_SPRITES | IGNORE_CONTENT) > 0)
{
camera.pan = me.pan;
vec_set(camera.x,target);
vec_add(camera.x,normal);
}
else
{
camera.pan = me.pan;
camera.tilt = -(camera_distance/3);
camera.x = me.x - camera_distance * cos(me.pan);
camera.y = me.y - camera_distance * sin(me.pan);
camera.z = me.z + camera_distance;
}
and it was just the same.
Last edited by Theil; 10/13/11 00:27.
|
|
|
Re: c_trace for camera collision problem
[Re: Theil]
#385103
10/13/11 00:30
10/13/11 00:30
|
Joined: Sep 2009
Posts: 84
Theil
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2009
Posts: 84
|
I had to reduce the speed of the animation.
Last edited by Theil; 10/13/11 00:35.
|
|
|
Re: c_trace for camera collision problem
[Re: Theil]
#385158
10/13/11 19:11
10/13/11 19:11
|
Joined: Sep 2009
Posts: 84
Theil
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2009
Posts: 84
|
Anyone? this problem looks so simple but I can't find a way to solve it. =/
Last edited by Theil; 10/13/11 19:15.
|
|
|
Re: c_trace for camera collision problem
[Re: Theil]
#385173
10/14/11 02:20
10/14/11 02:20
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
You're tracing to the camera's position. When the camera is in front of the wall, the trace hits nothing, so you're putting it back at the old position. I recommend keeping track of where the camera would be if there were no obstacles, and trace to that position always. I hope this helps
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
|