Hello,
I've tried my very best to ensure that this isn't my code at fault. I posted this issue to the "Starting with Gamestudio" forum before copying it here. I created a level that can be used to reproduce the bug, which I'll link to below. I've spent most of three days researching it. Hopefully it's a bug, or I'll be very embarrassed! :-) I'm using 7.06.
Here's what's up. When doing a c_move, my entity sometimes gets "stuck" where concave blocks intersect.
I'll reiterate my process from my original post:
Step 1: Create a block
Step 2: Copy the block so that I have a grid of 9 blocks
Step 3: Convert each block to a concave block
Step 4: Rise up one corner of one of the triangles
Step 5: Rise up more corners of the surrounding triangles to create a "bump"
Step 6: Attempt to walk on the bump. Get stuck often.
I seem to get stuck where the blocks meet. Here's a screen capture of one of the positions my entity has gotten stuck at:
When I say that the entity is getting stuck, I mean that attempting to move the entity using c_move doesn't work. I added logging to my script that prints out the entity's position and movement vectors. The code:
Code:
// Move the player
distance_moved = c_move(me, move_to_vector, nullvector, GLIDE|IGNORE_SPRITES|IGNORE_PASSABLE);
if (key_z)
{
diag_var("\nx: %6.3f",my.x);
diag_var("\ny: %6.3f",my.y);
diag_var("\nz: %6.3f",my.z);
diag_var("\ndistance to ground: %6.3f",distance_to_ground);
diag_var("\nmove to x: %6.3f",move_to_vector.x);
diag_var("\nmove to y: %6.3f",move_to_vector.y);
diag_var("\nmove to z: %6.3f",move_to_vector.z);
diag_var("\ndistance moved: %6.3f", distance_moved);
diag_var("\nin solid: %6.3f",in_solid);
}
And here is 2 frames of the output:
x: -512.035
y: 236.587
z: 136.929
distance to ground: 0.000
move to x: 2.971
move to y: 0.000
move to z: 0.000
distance moved: 0.000
in solid: 0.000
// .. next loop
x: -512.035
y: 236.587
z: 136.929
distance to ground: 0.000
move to x: 2.979
move to y: 0.000
move to z: 0.000
distance moved: 0.000
Notice that I'm attempting to move the entity forward 2.979 quants. c_move isn't moving the entity. However, it's also not reporting that I'm stuck in a block. During these frames, I'm not trying to move in the z-direction. distance_moved is set to 0.
I took my project and stripped it down to the bare essentials for testing. I was able to create a project where you can easily recreate the issue. You can
download my example project here. In the demo, if you hit 'p', you'll be positioned to a trouble spot that's easy to get stuck on. Try hitting 'p', then a or d to strafe left or right. You should immediately find yourself stuck.
Here's my movement code:
Code:
action move_me()
{
VECTOR move_to_vector; // Holds the relative x,y,z values that are added to the character's position
var distance_to_ground;
var distance_moved;
move_to_vector.x = 0;
move_to_vector.y = 0;
move_to_vector.z = 0;
wait(1);
c_setminmax(me);
vec_set(my.min_x,vector(-8,-8,-20));
vec_set(my.max_x,vector(8,8,20));
while(1)
{
accelerate(move_to_vector.y, (key_d * strafe_speed * time_step * -1), 0.8); // strafe right
accelerate(move_to_vector.y, (key_a * strafe_speed * time_step), 0.8); // strafe left
accelerate(move_to_vector.x, (key_w * run_speed * time_step), 0.8); // go forward
accelerate(move_to_vector.x, (key_s * run_speed * time_step * -1), 0.8); // go back
distance_to_ground = c_trace(my.x, vector(my.x,my.y,my.z - 500), IGNORE_ME|IGNORE_PASSENTS|IGNORE_PASSABLE|IGNORE_SPRITES|USE_BOX);
move_to_vector.z = -1 * distance_to_ground;
distance_moved = c_move(me, move_to_vector, nullvector, GLIDE|IGNORE_SPRITES|IGNORE_PASSABLE);
wait(1);
}
}
I've tried compiling my level with Don't snap verticies on and off. I've also tried Merge across leaves. Neither makes a difference.
Thanks!
- Bret