1 registered members (TipmyPip),
18,466
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Issue with my collision detectio script
#149303
08/21/07 04:02
08/21/07 04:02
|
Joined: Jun 2007
Posts: 18 Houston. TX, USA
Cyan
OP
Newbie
|
OP
Newbie
Joined: Jun 2007
Posts: 18
Houston. TX, USA
|
I know this has been beaten to death on the forums, but I found nothing that addressed my particular problem. Here's the collision detection I'm using from the script corresponding to the "player": Code:
//////////////////////////// function collision_check() { dot_front_left[0] = my.x - 15; dot_front_left[1] = my.y + 25; dot_front_left[2] = my.z; dot_front_right[0] = my.x + 15; dot_front_right[1] = my.y + 25; dot_front_right[2] = my.z; dot_back_left[0] = my.x - 15; dot_back_left[1] = my.y - 25; dot_back_left[2] = my.z; dot_back_right[0] = my.x + 15; dot_back_right[1] = my.y - 25; dot_back_right[2] = my.z; dot_right_front[0] = my.x + 25; dot_right_front[1] = my.y + 15; dot_right_front[2] = my.z; dot_right_back[0] = my.x + 25; dot_right_back[1] = my.y - 15; dot_right_back[2] = my.z; dot_left_front[0] = my.x - 25; dot_left_front[1] = my.y + 15; dot_left_front[2] = my.z; dot_left_back[0] = my.x - 25; dot_left_back[1] = my.y - 15; dot_left_back[2] = my.z;
me = my; trace_mode = ignore_me; if (trace(dot_front_left.x, dot_front_right.x) != 0) {move_forward = no;} else {move_forward = yes;} if (trace(dot_back_left.x, dot_back_right.x) != 0) {move_back = no;} else {move_back = yes;} if (trace(dot_left_front.x, dot_left_back.x) != 0) {move_left = no;} else {move_left = yes;} if (trace(dot_right_front.x, dot_right_back.x) != 0) {move_right = no;} else {move_right = yes;} me = blank_ent; }
//////////////////////////// It works great with blocks, but I can still pass through models. Help would be greatly appreciated. P.S. I know about c_move and c_trace, but I'd like to see if this can be fixed first before I try to code what looks like a completely different kind of collision detection. my.passable = off didn't work, and neither did my.polygon = on. P.S.S. The models that the player passes through are animated, but they're in their "wait" frames, so they do not move.
Last edited by Cyan; 08/21/07 04:03.
|
|
|
Re: Issue with my collision detectio script
[Re: Cyan]
#149304
08/21/07 14:57
08/21/07 14:57
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
Serious User
|
Serious User
Joined: Nov 2005
Posts: 1,007
|
do the other models have their my.passable = off flags set? or you could try c_setminmax(me);
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Didn't work
[Re: jigalypuff]
#149305
08/21/07 15:22
08/21/07 15:22
|
Joined: Jun 2007
Posts: 18 Houston. TX, USA
Cyan
OP
Newbie
|
OP
Newbie
Joined: Jun 2007
Posts: 18
Houston. TX, USA
|
1) yes, in fact here is the code for the other model: Code:
///////////////////////////////////////////////////// action kafua_act // attached to the first enemy that appears in the desert level { while (1) { c_setminmax(me); my.narrow=on; my.fat=off; my.passable = off; // not passable if ((vec_dist (my.x, player.x) < 75) && (key_enter == 1)) // if the player comes closer than 75 quants to Kafua and presses Enter {
my.pan = player.pan; my.pan += 180; // text processing starts here str_cpy(temp_str, line1_str); // that's the "Why do you bother me? I'm trying to... " line process_their_strings(); wait (1); theysay_txt.string = their_lines_str; theysay_txt.visible = on; wait (3); stop_player = 1; // stop the player for now sleep (2); // wait for 2 seconds isay1_txt.visible = on; // give the player the possibility to answer (this will bring up the my_pan panel as well) isay2_txt.visible = on; show_pointer = 1; // display the mouse pointer while (their_pan.visible == on) {wait (1);} // stop the skeleton until this panel disappears stop_player = 0; // allow the player to move again // text processing ends here } wait (1); } } 2) I put that in, but it had no effect. 
Last edited by Cyan; 08/21/07 15:25.
|
|
|
Re: Didn't work
[Re: Cyan]
#149306
08/21/07 15:41
08/21/07 15:41
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
Serious User
|
Serious User
Joined: Nov 2005
Posts: 1,007
|
try moving the my.pasable = off to outside of your while loop, i think it should be before it Code:
my.passable = off; while (1) { rest of your code }
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: Hmm
[Re: EpsiloN]
#149310
08/22/07 19:29
08/22/07 19:29
|
Joined: Jun 2007
Posts: 18 Houston. TX, USA
Cyan
OP
Newbie
|
OP
Newbie
Joined: Jun 2007
Posts: 18
Houston. TX, USA
|
Alright, I just re-read the Collision Detection section of the Help file over and over again, and now I'm confused. It told you what it did, but it didn't really go into how to set it up. I put in c_move(my,vector(5*time,0,0),nullvector,USE_AABB); near the top of my player action, but nothing happened. I then put it in the while(1) loop, and then my player started sliding all over the place. Say I wanted to ditch the current collision detection and go back to the default. How would I go about doing that? P.S. I'm not using templates for this game. They were starting to hold me back. EDIT: C-Script for action.player1: Code:
action player1 { player = my; // I'm the player
my.x = -80; // set the proper position and orientation for the player my.y = 800; // this is useful if you have a huge level and the player is too small to be noticeable on the map in Wed my.z = 64; my.pan = -90; my.transparent = off; // the player is not transparent my.polygon = on; my.passable= off; my.alpha = 100; // but opaque if the camera doesn't run into obstacles my.skill40 = camera_distance; // we store the distance to the camera my.skill41 = camera_height; // and its height camera_mode = 3; // the game starts with the camera in 3rd person mode while (1) { while (stop_player == 1) {wait (1);} collision_check(); ////////////////////// c_move(my,vector(5*time,0,0),nullvector,USE_AABB); if (key_enter == 1) {event_check();} /////////////////////////PLAYER DIRECTIONAL MOVEMENT if (key_shift == 1) {speed = 18;} else {speed = 8;} // makes Matoran walk faster if (key_cuu + key_cud + key_cur + key_cul > 0) // if the player is walking { ////////UP if (key_cuu == 1) { my.pan = 90; if (move_forward == yes) { my.y += speed*time; player_state = walk;} else {player_state = wait;} } //////////DOWN if (key_cud == 1) { my.pan = -90; if (move_back == yes) { my.y -= speed*time; player_state = walk; }else {player_state = wait;} } ///////RIGHT if (key_cur == 1) { my.pan = 0; if (move_right == yes) { my.x += speed*time; player_state = walk; }else {player_state = wait;} } // LEFT if (key_cul == 1) { my.pan = 180; if (move_left == yes) { my.x -= speed*time; player_state = walk; }else {player_state = wait;} } ////////UP RIGHT if (key_cuu == 1) && (key_cur ==1) { my.pan = 45; if (move_forward == yes) && (move_right == yes) { my.y += speed*time; my.x += speed*time; player_state = walk;} else {player_state = wait;} } //////// DOWN RIGHT if (key_cud == 1) && (key_cur ==1) { my.pan = -45; if (move_back == yes) && (move_right == yes) { my.y -= speed*time; my.x += speed*time; player_state = walk;} else {player_state = wait;} } //////// UP LEFT if (key_cuu == 1) && (key_cul ==1) { my.pan = 135; if (move_forward == yes) && (move_left == yes) { my.y += speed*time; my.x -= speed*time; player_state = walk;} else {player_state = wait;} } //////// DOWN LEFT if (key_cud == 1) && (key_cul ==1) { my.pan = -135; if (move_back == yes) && (move_left == yes) { my.y -= speed*time; my.x -= speed*time; player_state = walk;} else {player_state = wait;} } /////////////////////////////////// ent_cycle("walk", my.skill46); // play its "walk" frames animation my.skill46 += 10 * (1 + key_shift * 0.5) * time; // the animation speed increases when the player presses the "shift" key my.skill46 %= 100; // loop the animation } else // if the player is standing { my.skill47 = 0; // reset the skill that stores the distance needed for the step sound (not really needed) ent_cycle("stand", my.skill48); // play the "stand" frames animation my.skill48 += 2 * time; // "stand" animation speed my.skill48 %= 100; // loop animation } my.skill47 += ent_move (temp, nullvector); if (my.skill47 > 50) // play with 50 (here we've got a step sound every 50 quants) { snd_play(step_wav, 30, 0); my.skill47 = 0; } wait (1); } } ////////////////////////////
Last edited by Cyan; 08/22/07 19:31.
|
|
|
Re: Hmm
[Re: Cyan]
#149311
08/22/07 22:13
08/22/07 22:13
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
Serious User
|
Serious User
Joined: Nov 2005
Posts: 1,007
|
my.polygon = on; comment that out
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
|