Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,008 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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
C
Cyan Offline OP
Newbie
Cyan  Offline OP
Newbie
C

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 Offline
Serious User
jigalypuff  Offline
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
C
Cyan Offline OP
Newbie
Cyan  Offline OP
Newbie
C

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 Offline
Serious User
jigalypuff  Offline
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: Didn't work [Re: jigalypuff] #149307
08/21/07 16:34
08/21/07 16:34
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Think about what your script is doing. Its tracing lines between some points forming a box around your model. Edges. What about the 'faces' of this box You have to trace between every edge 60 times per face,for 6 faces ,thats 360 traces to make your collision detection similar to the default. There is no point doing that,because it'll slow your engine untill it becomes something like a slideshow

PS.: I'm talking about tracing every quant,forming a grid of 'edges'.


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Hmm [Re: EpsiloN] #149308
08/22/07 02:19
08/22/07 02:19
Joined: Jun 2007
Posts: 18
Houston. TX, USA
C
Cyan Offline OP
Newbie
Cyan  Offline OP
Newbie
C

Joined: Jun 2007
Posts: 18
Houston. TX, USA
So I should just use the default collision detection, but does that require scripting, or can it be done in WED? Having to use that c_move and c_rotate everytime my player wants to walk or turn would probably result in me having to rewrite all my code (all my player code anyway).

Re: Hmm [Re: Cyan] #149309
08/22/07 03:45
08/22/07 03:45
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Dunno about rotate but I always use move and only one time per entity easy enough and btw I use only ent_move. I'm used to the older commands...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Hmm [Re: EpsiloN] #149310
08/22/07 19:29
08/22/07 19:29
Joined: Jun 2007
Posts: 18
Houston. TX, USA
C
Cyan Offline OP
Newbie
Cyan  Offline OP
Newbie
C

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 Offline
Serious User
jigalypuff  Offline
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!
Re: Hmm [Re: jigalypuff] #149312
08/23/07 19:33
08/23/07 19:33
Joined: Jun 2007
Posts: 18
Houston. TX, USA
C
Cyan Offline OP
Newbie
Cyan  Offline OP
Newbie
C

Joined: Jun 2007
Posts: 18
Houston. TX, USA
Collision works now! I just needed to replace my.y -= speed*time; with c_move (my, nullvector, vector(0, speed*time, 0), GLIDE);

Someone said that already, but I didn't understand what they meant. Thanks for the help, but expect another question soon because I'm having problems with keyboard functions.


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

Gamestudio download | 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