Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, TedMar, dr_panther), 1,049 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
c_trace for camera collision problem (SOLVED) #385093
10/12/11 20:02
10/12/11 20:02
Joined: Sep 2009
Posts: 84
Theil Offline OP
Junior Member
Theil  Offline OP
Junior Member

Joined: Sep 2009
Posts: 84
I've got this piece of code for the camera on a third person view

Code:
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: Theil] #385100
10/12/11 23:30
10/12/11 23:30
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
i'd put an epilepsy warning on this thread tongue

try setting the camera.pan before you calculate position

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 Offline OP
Junior Member
Theil  Offline 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

Code:
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 Offline OP
Junior Member
Theil  Offline 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 Offline OP
Junior Member
Theil  Offline 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
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

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 laugh


Formerly known as JulzMighty.
I made KarBOOM!
Re: c_trace for camera collision problem [Re: JibbSmart] #385189
10/14/11 13:31
10/14/11 13:31
Joined: Sep 2009
Posts: 84
Theil Offline OP
Junior Member
Theil  Offline OP
Junior Member

Joined: Sep 2009
Posts: 84
Wow thank you JibbSmart, that solved my problem, I defined a vector with the position of where the camera should be and traced the ray from there to the player and it worked perfectly, Thank you very much.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1