1 registered members (AndrewAMD),
1,248
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Camera Collision
#207654
05/21/08 13:45
05/21/08 13:45
|
Joined: Oct 2007
Posts: 27
Skeksis
OP
Newbie
|
OP
Newbie
Joined: Oct 2007
Posts: 27
|
I've been using the Kingdom Hearts movement and camera for a while now, and never really had any problems when I was using blocks in wed. Now all my levels are models, and I'm having issues with clipping. I've been trying for the past few days to solve this but haven't been able to. I'm wondering if someone could help me out, I just want the camera to not clip through models, any help will be appreciated. Below is the camera function.
FUNCTION handle_camera() { camera_pan -= mouse_force.x * 12 * time; camera_tilt += mouse_force.y * 8 * time; camera_tilt = clamp(camera_tilt,-70,50);
camera.pan = camera_pan; temp = fcos(camera_tilt,-camera_distance); vec_set(camera_move_to.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + 20 + fsin(camera_tilt,-camera_distance)));
temp = min(1,2 * time); camera.x += temp*(camera_move_to.x - camera.x); camera.y += temp*(camera_move_to.y - camera.y); camera.z += temp*(camera_move_to.z - camera.z);
vec_diff(temp.x,camera.x,my.x); vec_normalize(temp.x,16); vec_add(temp.x,camera.x);
IF (c_trace(my.x,temp.x,ignore_me) > 0) { vec_diff(temp.x,my.x,target.x); vec_normalize(temp.x,16); vec_set(camera.x,target.x); vec_add(camera.x,temp.x); }
vec_diff(temp.x,my.x,camera.x); vec_to_angle(camera.pan,temp.x); }
Last edited by Skeksis; 05/21/08 13:46.
|
|
|
Re: Camera Collision
[Re: Christian__A]
#207725
05/21/08 21:40
05/21/08 21:40
|
Fear411
Unregistered
|
Fear411
Unregistered
|
does you model have the polygon or box flag attached?
|
|
|
Re: Camera Collision
[Re: Skeksis]
#207991
05/23/08 21:39
05/23/08 21:39
|
Joined: Oct 2002
Posts: 2,256 Oz
Locoweed
Expert
|
Expert
Joined: Oct 2002
Posts: 2,256
Oz
|
You can first try changing:
IF (c_trace(my.x,temp.x,ignore_me) > 0) { To IF (c_trace(my.x,temp.x,ignore_me+use_box) > 0) {
If that doesn't fix it you can also make 16 a larger number in
vec_normalize(temp.x,16); For example: vec_normalize(temp.x,32);
That the larger that number is the farther back the camera will be placed from collision point (Target) on model or block.
Although I would write code like this if using use_box and c_trace:
c_trace(my.x,temp.x,ignore_me+use_box); IF (trace_hit) { vec_diff(temp.x,my.x,target.x); vec_normalize(temp.x,16); // make 16 larger to pull camera farther off of collision point vec_set(camera.x,target.x); vec_add(camera.x,temp.x); }
Loco
Professional A8.30 Spoils of War - East Coast Games
|
|
|
|